@astram/frontend-core

中文文档
0.16.0发布于 2026/11/06MITTypeScriptES Module零依赖近 30 天下载 3376

Astram framework — the frontend logic core. Platform-agnostic auth + identity SERVICES over an injected HTTP client (no React/DOM/fetch/storage baked in): login, MFA, profile, companies/users/roles/membership CRUD, audit. The frontend half of the framewor

原始使用文档
文档目录4 节
  1. Proposals ( createProposalService )
  2. Rendering contract
  3. Proposals created during an agent task ( AgentTaskState.app…
  4. Agent plan and workers ( AgentTaskState.plan , .workers )

@astram/frontend-core

Platform-agnostic auth, identity, agent and proposal services over an injected HttpClient (no React, DOM, fetch or storage built in). Each create…Service(http) factory takes the app's HTTP client, receives the bearer token per call and resolves to { ok: true, … } or { ok: false, status, error } with fixed text; it never throws for an HTTP error.

Proposals (createProposalService)

Client for the governed proposal routes /identity/proposals… (agent-proposals SPEC §3, §5 H): list, get, submit, select, approve, reject, withdraw, apply. A failure also carries code (one of PROPOSAL_ERROR_CODES, or null) and, where the server named them, itemIndex / itemIndexes. (SPEC v8) screened (422: the kind's screen refused the draft; screenCode is the kind's declared code or screen_failed, for your own wording) and submit_app_only (403: the kind accepts submits from app code only).

Rendering contract

  • Values are text, never HTML. Render title, rationale, metadata.assumptions, metadata.uncertainty.note, evidence notes, impact.summary, item issue messages and every label as text nodes only (no innerHTML, dangerouslySetInnerHTML, v-html or markdown).
  • preview cells are HTML-escaped by the server. Pass each cell through previewCellText(cell) and render the result as text. Never insert a cell as HTML.
  • Ids are for linking, never displayed. uuid, provenance.taskId / callId, item targetId / resultId, evidence ids and apply results[].id may be used in routes and API calls only. Show a resolved label instead (kindLabel, requester.label, decided.byLabel, history[].actorLabel, or a label the app resolves for a target record); show a neutral fallback when no label resolves. A review page must have a test that no uuid-shaped text renders.
  • Provenance is server-set. submit sends only kind, payload, title, rationale? and metadata?; the server refuses origin, taskId or callId in a body.
  • Show error (fixed text), never a server message.

Proposals created during an agent task (AgentTaskState.approvals)

When an agent propose capability creates a proposal, the agent stream sends approval.required { proposalId, kind, title }. agentReducer keeps these in AgentTaskState.approvals (readonly AgentApproval[], [] in INITIAL_AGENT_STATE): text fields only (anything else in the payload is dropped; a payload missing one of the three is ignored), one entry per proposalId (a replayed event adds nothing), in arrival order, kept across the task's runs. Render kind and title as text and use proposalId only to link to the review page (never display it); fetch the details with createProposalService(http).get(accessToken, proposalId).

Agent plan and workers (AgentTaskState.plan, .workers)

The agent stream may send the agent's todo list and its helpers (docs/features/agent-plan-line/SPEC.md):

  • plan ⇒ AgentTaskState.plan (readonly AgentPlanItem[] | null): each event replaces the list after a shape check (1–12 items, a string id and title, status pending | in_progress | done); a malformed event is ignored. Render titles as text only (never HTML or markdown): they are model-written. id is a rendering key, never displayed.
  • worker.started / worker.finished ⇒ AgentTaskState.workers, keyed by the app-assigned worker number as a string ('1', '2', …) with { profile, status, code }; a request the app denied has no number and is keyed d1, d2, … in arrival order (never merged with a numbered worker). profile is reader or analyst: map it to your own label.
  • tool.started with a worker number ⇒ AgentToolState.worker, so a worker's calls can be grouped under it.
  • task.started resets plan to null and workers to {} (each run starts empty).
  • getTask returns the task view's last plan (or null).

版本与发布记录

@astram/frontend-core 共发布 23 个版本,首次发布于 2026/07/18;过去 12 个月发布了 23 个版本。

版本发布日期距今
0.16.0latest2026/11/062 天前
0.15.12026/11/044 天前
0.15.02026/11/034 天前
0.14.02026/11/034 天前
0.13.02026/10/317 天前
0.12.12026/10/317 天前

关于 @astram/frontend-core 的常见问题

@astram/frontend-core 是什么?

Astram framework — the frontend logic core. Platform-agnostic auth + identity SERVICES over an injected HTTP client (no React/DOM/fetch/storage baked in): login, MFA, profile, companies/users/roles/membership CRUD, audit. The frontend half of the framewor

如何安装 @astram/frontend-core?

在项目目录运行 npm install @astram/frontend-core,或使用 pnpm add / yarn add / bun add。

@astram/frontend-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@astram/frontend-core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@astram/frontend-core 可以商用吗?

@astram/frontend-core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@astram/frontend-core 的下载量有多少?

根据 npm 官方下载统计,@astram/frontend-core 在 2026/10/07 – 2026/11/05 这 30 天内被下载 3,376 次,日均约 113 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@astram/frontend-core 还在维护吗?

最新版本 0.16.0 发布于 2026/11/06(2 天前);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/07/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。