You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement the first working assistant slice for social post drafting:
A local/testable workflow accepts a mock Telegram message that asks for social posts and turns it into a social drafting assistant run.
The assistant uses z.ai through the Anthropic-compatible Messages API with ZAI_API_KEY and default model glm-5.2.
The assistant drafts X/Twitter and LinkedIn copy in the style of historical Typefully posts.
The workflow creates a Typefully saved draft, not a scheduled or published post.
The assistant chooses the target Typefully social set/account from the request, supporting Alexey / Al_Grigor and DataTalksClub. If the target is ambiguous, it must fail safely or produce a review-required result instead of writing to the wrong account.
Real Telegram webhook delivery and real external writes remain behind human/manual verification. The required automated proof is local with mocked Telegram input and mocked z.ai/Typefully clients.
The current uncommitted scripts/typefully/ utilities are supporting context, not required product scope. The engineer may reuse or adapt small pieces if that is the lowest-risk path, but this issue should not depend on committing the full export/analysis tooling. Historical style examples used by tests must be sanitized fixtures or generated test data, not private .tmp/typefully* exports.
Acceptance Criteria
A mock Telegram social drafting request can be processed locally into a social drafting assistant run without requiring a real Telegram webhook.
The assistant request captures the source Telegram text, target account/social set, target platforms (x and linkedin), requested intent, and review status in DataOps state or an assistant output artifact.
The z.ai client is implemented behind a small interface that is mockable in tests and uses the Anthropic-compatible Messages API with:
ZAI_API_KEY
default model glm-5.2
base URL compatible with the reference implementation (https://api.z.ai/api/anthropic)
no secret logging or persistence
The Typefully draft client is implemented behind a small interface that is mockable in tests, creates saved drafts only, and never schedules or publishes.
Account selection supports at least these explicit hints:
Alexey / Al_Grigor
DataTalksClub / DTC
Ambiguous account selection does not create a Typefully draft and leaves a clear review/error state.
Prompt/context assembly includes historical style examples for both X/Twitter and LinkedIn, separated by account where possible. Test fixtures must be sanitized and public-safe.
Automated tests cover a successful mocked Telegram-to-Typefully draft flow for Alexey / Al_Grigor.
Automated tests cover a successful mocked Telegram-to-Typefully draft flow for DataTalksClub.
Automated tests cover ambiguous account handling and verify no Typefully write happens.
Automated tests cover z.ai and Typefully failure handling without leaking ZAI_API_KEY, TYPEFULLY_API_KEY, Telegram tokens, private draft URLs, or raw private exports in logs/errors.
Local configuration/readiness is documented for ZAI_API_KEY, Typefully API credentials/social-set identifiers, and Telegram webhook variables needed for real integration.
[HUMAN] With a real ZAI_API_KEY, an operator may run the assistant against z.ai and inspect the generated copy quality.
[HUMAN] With a real Typefully key, an operator may create one saved Typefully draft and confirm it is unscheduled/unpublished and attached to the intended account.
[HUMAN] Real Telegram webhook delivery, bot/channel/group permissions, and deployed webhook secret setup are verified by an operator before production use.
Test Scenarios
Scenario: Alexey draft from mock Telegram
Given: mocked z.ai and Typefully clients, sanitized Alexey / Al_Grigor X and LinkedIn style examples, and a mock Telegram message that asks for Alexey social posts
When: the local assistant workflow processes the message
Then: it selects Alexey / Al_Grigor, asks z.ai for draft copy, creates a mocked Typefully saved draft for X and LinkedIn, and records the draft metadata without secrets.
Scenario: DataTalksClub draft from mock Telegram
Given: mocked z.ai and Typefully clients, sanitized DataTalksClub X and LinkedIn style examples, and a mock Telegram message that asks for DTC/DataTalksClub social posts
When: the local assistant workflow processes the message
Then: it selects the DataTalksClub social set, drafts account-appropriate X and LinkedIn copy, creates a mocked Typefully saved draft, and records the review-required result.
Scenario: Ambiguous account
Given: mocked z.ai and Typefully clients and a mock Telegram message that does not identify Alexey or DataTalksClub
When: the local assistant workflow processes the message
Then: it does not call Typefully, records a clear ambiguous-account state, and leaves the item/job ready for human clarification.
Scenario: Provider failure
Given: mocked z.ai or Typefully failures
When: the assistant workflow runs
Then: the job/result records a sanitized failure state, no secret values or private draft URLs appear in persisted metadata or logs, and retries/manual review remain possible according to the existing assistant job lifecycle.
Required Verification
npm --prefix work-engine test
npm --prefix work-engine run typecheck
npm --prefix work-engine run build
Focused tests for the new mocked Telegram/social assistant flow.
npm --prefix work-engine run test:e2e only if the implementation changes operator UI, route behavior beyond unit/API coverage, or end-to-end workflow behavior that cannot be proven by the focused tests. If skipped, Tester must explain why the focused API/unit coverage is enough for this backend assistant slice.
Assistant Engineer review is recommended for prompt/tool boundaries before Tester review because this introduces a new assistant workflow.
Out of Scope
Publishing or scheduling posts in Typefully.
Real Telegram webhook deployment, bot setup, channel/group permission setup, or production webhook verification except as [HUMAN] readiness checks.
Real external writes during automated tests.
Committing raw Typefully exports, private draft URLs, private social copy archives, credentials, screenshots, sponsor/finance/contact details, or operational SOPs into this public repo.
Migrating all scripts/typefully/ export/analysis utilities into production code.
Frontend UI changes unless the engineer finds a minimal existing assistant-job surface update necessary for visibility.
Changes to ../dtc-operations, ../datatasks, ../podcast-assistant, or ../ai-engineering-field-guide.
Dependencies
Local development requires ZAI_API_KEY only for optional real z.ai verification. Automated tests must use mocks.
Real Typefully draft creation requires Typefully API credentials and known social-set identifiers for Alexey / Al_Grigor and DataTalksClub. Automated tests must use mocks.
Production use will require deployed secret/config plumbing for z.ai, Typefully, and Telegram webhook settings through the existing DataOps deployment path; do not hardcode secrets or depend on another app's local secret store.
Build Telegram-to-Typefully social draft assistant
Status: automated acceptance passed - pending HUMAN external checks
Tags:
enhancement,assistant,work-engine,backend,infra,P1Depends on: None
Blocks: None
Scope
Implement the first working assistant slice for social post drafting:
ZAI_API_KEYand default modelglm-5.2.Al_Grigorand DataTalksClub. If the target is ambiguous, it must fail safely or produce a review-required result instead of writing to the wrong account.Relevant local surfaces:
work-engine/src/routes/telegram.tswork-engine/src/routes/assistantJobs.ts,work-engine/src/db/assistantJobs.tswork-engine/tests/telegram.test.tsscripts/typefully/../ai-engineering-field-guide/job-market/_internal/extract_llm.pyThe current uncommitted
scripts/typefully/utilities are supporting context, not required product scope. The engineer may reuse or adapt small pieces if that is the lowest-risk path, but this issue should not depend on committing the full export/analysis tooling. Historical style examples used by tests must be sanitized fixtures or generated test data, not private.tmp/typefully*exports.Acceptance Criteria
xandlinkedin), requested intent, and review status in DataOps state or an assistant output artifact.ZAI_API_KEYglm-5.2https://api.z.ai/api/anthropic)Al_GrigorAl_Grigor.ZAI_API_KEY,TYPEFULLY_API_KEY, Telegram tokens, private draft URLs, or raw private exports in logs/errors.ZAI_API_KEY, Typefully API credentials/social-set identifiers, and Telegram webhook variables needed for real integration.ZAI_API_KEY, an operator may run the assistant against z.ai and inspect the generated copy quality.Test Scenarios
Scenario: Alexey draft from mock Telegram
Given: mocked z.ai and Typefully clients, sanitized Alexey /
Al_GrigorX and LinkedIn style examples, and a mock Telegram message that asks for Alexey social postsWhen: the local assistant workflow processes the message
Then: it selects Alexey /
Al_Grigor, asks z.ai for draft copy, creates a mocked Typefully saved draft for X and LinkedIn, and records the draft metadata without secrets.Scenario: DataTalksClub draft from mock Telegram
Given: mocked z.ai and Typefully clients, sanitized DataTalksClub X and LinkedIn style examples, and a mock Telegram message that asks for DTC/DataTalksClub social posts
When: the local assistant workflow processes the message
Then: it selects the DataTalksClub social set, drafts account-appropriate X and LinkedIn copy, creates a mocked Typefully saved draft, and records the review-required result.
Scenario: Ambiguous account
Given: mocked z.ai and Typefully clients and a mock Telegram message that does not identify Alexey or DataTalksClub
When: the local assistant workflow processes the message
Then: it does not call Typefully, records a clear ambiguous-account state, and leaves the item/job ready for human clarification.
Scenario: Provider failure
Given: mocked z.ai or Typefully failures
When: the assistant workflow runs
Then: the job/result records a sanitized failure state, no secret values or private draft URLs appear in persisted metadata or logs, and retries/manual review remain possible according to the existing assistant job lifecycle.
Required Verification
npm --prefix work-engine testnpm --prefix work-engine run typechecknpm --prefix work-engine run buildnpm --prefix work-engine run test:e2eonly if the implementation changes operator UI, route behavior beyond unit/API coverage, or end-to-end workflow behavior that cannot be proven by the focused tests. If skipped, Tester must explain why the focused API/unit coverage is enough for this backend assistant slice.Out of Scope
[HUMAN]readiness checks.scripts/typefully/export/analysis utilities into production code.../dtc-operations,../datatasks,../podcast-assistant, or../ai-engineering-field-guide.Dependencies
ZAI_API_KEYonly for optional real z.ai verification. Automated tests must use mocks.Al_Grigorand DataTalksClub. Automated tests must use mocks.