@c4a/context-cli 0.7.97 → 0.7.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/README.zh-CN.md +2 -0
- package/cli.js +139 -19
- package/indexers/contracts/profile-contract.json +245 -245
- package/indexers/release-manifest.json +1 -1
- package/package.json +12 -12
- package/plugins/VERSION +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/commands/context.md +1 -1
- package/plugins/codex/.codex-plugin/plugin.json +2 -2
- package/plugins/codex/skills/context/SKILL.md +1 -1
- package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
- package/plugins/cursor/commands/c4a-context.md +1 -1
- package/plugins/skills/context/SKILL.md +1 -1
- package/providers/context/manifest.json +7 -7
- package/providers/context/provider.yaml +1 -1
- package/providers/context/resources/manuals/guides/lark-resources.md +2 -0
- package/providers/context/resources/procedures/document-capture.md +7 -1
package/README.md
CHANGED
|
@@ -320,7 +320,10 @@ MIT.
|
|
|
320
320
|
mode, a credential/scope/access failure retries once as the current user; the
|
|
321
321
|
rest of that capture keeps the fallback identity for pagination and resources.
|
|
322
322
|
Network, rate-limit and parsing errors do not trigger a user authorization
|
|
323
|
-
attempt.
|
|
323
|
+
attempt. The capture report records which identity read the document and why a
|
|
324
|
+
fallback happened; `context status` keeps warning about the fallback, because
|
|
325
|
+
content only that user can see is now in the snapshot and later bot captures may
|
|
326
|
+
not read it. This does not change source-read consent or the audience of published
|
|
324
327
|
knowledge. Host-managed OAuth must use the host's authorization flow.
|
|
325
328
|
|
|
326
329
|
### Workspace updates
|
package/README.zh-CN.md
CHANGED
|
@@ -71,6 +71,8 @@ Provider Skill 投影到 Claude、Codex 和 Cursor 的用户技能目录。
|
|
|
71
71
|
命令的 shell 都需传入该环境变量;仅在提示词中写配置并不会自动导出环境变量。
|
|
72
72
|
`bot` 模式先使用应用身份,遇到凭证、scope 或访问权限错误时回退当前用户一次,
|
|
73
73
|
本次采集后续分页、引用与资源下载沿用回退身份。网络、限流和解析错误不切换身份。
|
|
74
|
+
采集报告记录读取身份与回退原因;`context status` 会持续提示该回退:仅该用户可见的内容
|
|
75
|
+
已进入快照,之后用机器人采集可能读不到。
|
|
74
76
|
该配置不扩大来源授权或知识产物可见范围;托管运行时的用户授权遵循宿主流程。
|
|
75
77
|
|
|
76
78
|
## 一个 Agent 入口如何驱动整套工作流
|
package/cli.js
CHANGED
|
@@ -88325,7 +88325,37 @@ function createLarkCaptureReport(input) {
|
|
|
88325
88325
|
...descriptor?.title === undefined ? {} : { title: descriptor.title },
|
|
88326
88326
|
attributes: descriptor?.attributes ?? {}
|
|
88327
88327
|
};
|
|
88328
|
-
})
|
|
88328
|
+
}),
|
|
88329
|
+
...input.access === undefined ? {} : { access: input.access }
|
|
88330
|
+
};
|
|
88331
|
+
}
|
|
88332
|
+
function parseAccess(value) {
|
|
88333
|
+
if (value === undefined)
|
|
88334
|
+
return;
|
|
88335
|
+
if (!isRecord13(value) || value.identity !== "user" && value.identity !== "bot") {
|
|
88336
|
+
throw new TypeError("Lark capture report access.identity must be user or bot");
|
|
88337
|
+
}
|
|
88338
|
+
const fallback = value.fallback;
|
|
88339
|
+
if (fallback !== undefined && (!isRecord13(fallback) || fallback.from !== "bot" || typeof fallback.cause !== "string")) {
|
|
88340
|
+
throw new TypeError("Lark capture report access.fallback must name the bot and a cause");
|
|
88341
|
+
}
|
|
88342
|
+
if (value.events !== undefined && !Array.isArray(value.events))
|
|
88343
|
+
throw new TypeError("Lark capture report access.events must be an array");
|
|
88344
|
+
const events = value.events?.map((event, index2) => {
|
|
88345
|
+
if (!isRecord13(event) || typeof event.kind !== "string" || typeof event.message !== "string" || event.app_id !== undefined && typeof event.app_id !== "string" || event.changed_access !== undefined && typeof event.changed_access !== "boolean") {
|
|
88346
|
+
throw new TypeError(`Lark capture report access.events[${index2}] must have kind and message`);
|
|
88347
|
+
}
|
|
88348
|
+
return {
|
|
88349
|
+
kind: event.kind,
|
|
88350
|
+
message: event.message,
|
|
88351
|
+
...event.app_id === undefined ? {} : { app_id: event.app_id },
|
|
88352
|
+
...event.changed_access === undefined ? {} : { changed_access: event.changed_access }
|
|
88353
|
+
};
|
|
88354
|
+
});
|
|
88355
|
+
return {
|
|
88356
|
+
identity: value.identity,
|
|
88357
|
+
...fallback === undefined ? {} : { fallback: { from: "bot", cause: fallback.cause } },
|
|
88358
|
+
...events === undefined ? {} : { events }
|
|
88329
88359
|
};
|
|
88330
88360
|
}
|
|
88331
88361
|
function parseLarkCaptureReport(value) {
|
|
@@ -88361,6 +88391,7 @@ function parseLarkCaptureReport(value) {
|
|
|
88361
88391
|
if (materialization === undefined) {
|
|
88362
88392
|
throw new TypeError("Lark capture report resource_materialization is required");
|
|
88363
88393
|
}
|
|
88394
|
+
const access4 = parseAccess(value.access);
|
|
88364
88395
|
return {
|
|
88365
88396
|
schema_version: LARK_CAPTURE_REPORT_SCHEMA_VERSION,
|
|
88366
88397
|
fidelity,
|
|
@@ -88369,7 +88400,8 @@ function parseLarkCaptureReport(value) {
|
|
|
88369
88400
|
...item,
|
|
88370
88401
|
...enriched[index2]?.title === undefined ? {} : { title: enriched[index2].title },
|
|
88371
88402
|
attributes: enriched[index2]?.attributes ?? {}
|
|
88372
|
-
}))
|
|
88403
|
+
})),
|
|
88404
|
+
...access4 === undefined ? {} : { access: access4 }
|
|
88373
88405
|
};
|
|
88374
88406
|
}
|
|
88375
88407
|
function captureReportMaterialization(report) {
|
|
@@ -88378,6 +88410,18 @@ function captureReportMaterialization(report) {
|
|
|
88378
88410
|
items: report.resources.map(materializationItem)
|
|
88379
88411
|
};
|
|
88380
88412
|
}
|
|
88413
|
+
function sameLarkAccess(left, right) {
|
|
88414
|
+
const canonical = (value) => Array.isArray(value) ? value.map(canonical) : isRecord13(value) ? Object.fromEntries(Object.keys(value).sort().map((key) => [key, canonical(value[key])])) : value;
|
|
88415
|
+
return JSON.stringify(canonical(left)) === JSON.stringify(canonical(right));
|
|
88416
|
+
}
|
|
88417
|
+
function larkAccessDiagnostics(access4) {
|
|
88418
|
+
return [
|
|
88419
|
+
...access4?.fallback === undefined ? [] : [
|
|
88420
|
+
`warning: lark.capture.identity-fallback: the bot could not read this document (${access4.fallback.cause}), so it was read as the user. ` + "Content only that user can see is now in the snapshot, and later bot captures may not be able to read it; " + "ask the document's owner to share it with the bot"
|
|
88421
|
+
],
|
|
88422
|
+
...(access4?.events ?? []).map((event) => `info: lark.capture.${event.kind}: ${event.message}`)
|
|
88423
|
+
];
|
|
88424
|
+
}
|
|
88381
88425
|
var LARK_CAPTURE_REPORT_SCHEMA_VERSION = "context.lark-capture-report.v1";
|
|
88382
88426
|
var init_larkCaptureReport = __esm(() => {
|
|
88383
88427
|
init_src3();
|
|
@@ -88418,6 +88462,7 @@ function documentSnapshotFidelityState(manifest, captureReport) {
|
|
|
88418
88462
|
...(resources?.items ?? []).filter((item) => item.status === "failed" && item.required && !isNonBlockingDocumentResourceFailureReasonCode(item.reason_code)).map((item) => `lark.capture.resource-materialization-failed: ${item.kind}: ${item.reason ?? item.locator}`)
|
|
88419
88463
|
],
|
|
88420
88464
|
warnings: [
|
|
88465
|
+
...larkAccessDiagnostics(captureReport?.access).map((line) => line.replace(/^(?:warning|info): /u, "")),
|
|
88421
88466
|
...report === undefined ? [] : render((issue) => issue.impact === "projection" || issue.severity === "warning"),
|
|
88422
88467
|
...(resources?.items ?? []).filter((item) => item.reason_code === "document.resource.preview" || item.status === "failed" && (!item.required || isNonBlockingDocumentResourceFailureReasonCode(item.reason_code))).map((item) => `${item.reason_code ?? "lark.capture.resource-materialization-warning"}: ${item.kind}: ${item.reason ?? item.locator}`)
|
|
88423
88468
|
]
|
|
@@ -99588,6 +99633,9 @@ async function runDocumentCaptureWithAvailability(root, phase, capture2) {
|
|
|
99588
99633
|
state: source2.snapshotReady ? "retained-snapshot" : "deferred-no-evidence",
|
|
99589
99634
|
...source2.snapshotHash ? { snapshot_hash: source2.snapshotHash } : {},
|
|
99590
99635
|
retry_command: `context run ${phase.id}`,
|
|
99636
|
+
...typeof error.detail.next === "string" ? { next: error.detail.next } : {},
|
|
99637
|
+
...typeof error.detail.stderr === "string" ? { stderr: error.detail.stderr } : {},
|
|
99638
|
+
...Array.isArray(error.detail.access_events) ? { access_events: error.detail.access_events } : {},
|
|
99591
99639
|
message: source2.snapshotReady ? "Document refresh unavailable. Retain the validated registered snapshot; it is not confirmed current upstream." : "Document acquisition unavailable. Keep this source registered as a pending evidence gap; do not cite it or invent content. Unrelated work may continue."
|
|
99592
99640
|
};
|
|
99593
99641
|
await applyAtomicFileBatch({ transactionRoot: join99(root, ".tmp/context-runtime/transactions"), writes: [{ path: path2, bytes: `${JSON.stringify({ configuration, warning }, null, 2)}
|
|
@@ -108031,6 +108079,8 @@ function credentialFailure(result) {
|
|
|
108031
108079
|
continue;
|
|
108032
108080
|
const type = "type" in error ? error.type : undefined;
|
|
108033
108081
|
const subtype = "subtype" in error ? error.subtype : undefined;
|
|
108082
|
+
if ("code" in error && String(error.code) === LARK_DOCUMENT_ACCESS_DENIED_CODE)
|
|
108083
|
+
return true;
|
|
108034
108084
|
if (type === "authorization" || type === "authentication" || ["missing_scope", "permission_denied", "access_denied", "need_user_authorization"].includes(String(subtype))) {
|
|
108035
108085
|
return true;
|
|
108036
108086
|
}
|
|
@@ -108038,9 +108088,28 @@ function credentialFailure(result) {
|
|
|
108038
108088
|
}
|
|
108039
108089
|
return result.exitCode !== 0 && /reason=(?:bot_unavailable|not_authorized)\b|\b(?:missing_scope|permission_denied|access_denied)\b/iu.test(result.stderr);
|
|
108040
108090
|
}
|
|
108091
|
+
function failureCause(result) {
|
|
108092
|
+
for (const output of [result.stderr, result.stdout]) {
|
|
108093
|
+
const start2 = output.indexOf("{");
|
|
108094
|
+
if (start2 < 0)
|
|
108095
|
+
continue;
|
|
108096
|
+
try {
|
|
108097
|
+
const parsed = JSON.parse(output.slice(start2));
|
|
108098
|
+
const error = parsed && typeof parsed === "object" && "error" in parsed ? parsed.error : undefined;
|
|
108099
|
+
if (!error || typeof error !== "object")
|
|
108100
|
+
continue;
|
|
108101
|
+
const field = (key) => (key in error) ? String(error[key]) : undefined;
|
|
108102
|
+
if (field("code") !== undefined)
|
|
108103
|
+
return `lark error ${field("code")}`;
|
|
108104
|
+
return [field("type"), field("subtype")].filter(Boolean).join("/") || "credential failure";
|
|
108105
|
+
} catch {}
|
|
108106
|
+
}
|
|
108107
|
+
return /reason=(\w+)/u.exec(result.stderr)?.[1] ?? "credential failure";
|
|
108108
|
+
}
|
|
108041
108109
|
function createLarkReadSession(runner2, initial, fallback = initial === "bot") {
|
|
108042
108110
|
let identity2 = initial;
|
|
108043
108111
|
let usedFallback = false;
|
|
108112
|
+
let fallbackCause;
|
|
108044
108113
|
let readingDocument = false;
|
|
108045
108114
|
let locked = false;
|
|
108046
108115
|
const restart = new Error("Restart document with user identity");
|
|
@@ -108055,8 +108124,10 @@ function createLarkReadSession(runner2, initial, fallback = initial === "bot") {
|
|
|
108055
108124
|
withIdentity.push("--as", selected);
|
|
108056
108125
|
const result = await runner2(withIdentity, options);
|
|
108057
108126
|
identity2 = selected;
|
|
108058
|
-
if (readingDocument && identity2 === "bot" && fallback && !usedFallback && !args.includes("--help") && credentialFailure(result))
|
|
108127
|
+
if (readingDocument && identity2 === "bot" && fallback && !usedFallback && !args.includes("--help") && credentialFailure(result)) {
|
|
108128
|
+
fallbackCause = failureCause(result);
|
|
108059
108129
|
throw restart;
|
|
108130
|
+
}
|
|
108060
108131
|
return result;
|
|
108061
108132
|
};
|
|
108062
108133
|
async function readDocument(read) {
|
|
@@ -108076,15 +108147,24 @@ function createLarkReadSession(runner2, initial, fallback = initial === "bot") {
|
|
|
108076
108147
|
locked = true;
|
|
108077
108148
|
}
|
|
108078
108149
|
}
|
|
108079
|
-
return {
|
|
108080
|
-
|
|
108081
|
-
|
|
108082
|
-
|
|
108083
|
-
|
|
108150
|
+
return {
|
|
108151
|
+
run,
|
|
108152
|
+
readDocument,
|
|
108153
|
+
get identity() {
|
|
108154
|
+
return identity2;
|
|
108155
|
+
},
|
|
108156
|
+
get usedFallback() {
|
|
108157
|
+
return usedFallback;
|
|
108158
|
+
},
|
|
108159
|
+
get fallbackCause() {
|
|
108160
|
+
return fallbackCause;
|
|
108161
|
+
}
|
|
108162
|
+
};
|
|
108084
108163
|
}
|
|
108085
108164
|
var init_larkReadIdentity = __esm(() => {
|
|
108086
108165
|
init_errors3();
|
|
108087
108166
|
init_exitCode();
|
|
108167
|
+
init_larkResourceCommand();
|
|
108088
108168
|
});
|
|
108089
108169
|
|
|
108090
108170
|
// src/lib/feishu.ts
|
|
@@ -108460,17 +108540,25 @@ async function fetchFeishuDocSnapshot(input, runner2 = defaultRunner) {
|
|
|
108460
108540
|
}
|
|
108461
108541
|
});
|
|
108462
108542
|
}
|
|
108463
|
-
|
|
108543
|
+
const identityFallback = identityFetch.fallback || session.usedFallback;
|
|
108544
|
+
const access7 = {
|
|
108545
|
+
identity: accessIdentity,
|
|
108546
|
+
...session.usedFallback ? { fallback: { from: "bot", cause: session.fallbackCause ?? "credential failure" } } : {},
|
|
108547
|
+
...input.accessEvents?.length ? { events: [...input.accessEvents] } : {}
|
|
108548
|
+
};
|
|
108549
|
+
const sameAccess = !input.accessEvents?.some((event) => event.changed_access) && (input.unchangedAccess === undefined ? !identityFallback : sameLarkAccess(input.unchangedAccess, access7));
|
|
108550
|
+
if (sameAccess && revisionId !== undefined && revisionId === input.unchangedRevisionId && fidelity.evidence_status !== "error" && fidelity.projection_status !== "error" || input.requireCompleteBody === true && (fidelity.evidence_status === "error" || fidelity.projection_status === "error")) {
|
|
108464
108551
|
return {
|
|
108465
108552
|
markdown: body2,
|
|
108466
108553
|
...title2 === undefined ? {} : { title: title2 },
|
|
108467
108554
|
...revisionId === undefined ? {} : { revisionId },
|
|
108468
|
-
...revisionId === input.unchangedRevisionId && fidelity.evidence_status !== "error" && fidelity.projection_status !== "error" ? { unchanged: true } : {},
|
|
108555
|
+
...sameAccess && revisionId === input.unchangedRevisionId && fidelity.evidence_status !== "error" && fidelity.projection_status !== "error" ? { unchanged: true } : {},
|
|
108469
108556
|
assets,
|
|
108470
108557
|
fidelity,
|
|
108471
108558
|
resourceMaterialization,
|
|
108472
108559
|
accessIdentity,
|
|
108473
|
-
identityFallback
|
|
108560
|
+
identityFallback,
|
|
108561
|
+
access: access7
|
|
108474
108562
|
};
|
|
108475
108563
|
}
|
|
108476
108564
|
const resources = [...new Map([...projection?.resources ?? [], ...larkMarkdownImageResources(body2)].map((resource) => [resource.locator, resource])).values()];
|
|
@@ -108516,7 +108604,8 @@ async function fetchFeishuDocSnapshot(input, runner2 = defaultRunner) {
|
|
|
108516
108604
|
assets.push(captureReportAsset({
|
|
108517
108605
|
fidelity,
|
|
108518
108606
|
resourceMaterialization,
|
|
108519
|
-
resources
|
|
108607
|
+
resources,
|
|
108608
|
+
access: access7
|
|
108520
108609
|
}));
|
|
108521
108610
|
if (title2 !== undefined && title2.length > 0 && !/^#\s/.test(body2)) {
|
|
108522
108611
|
return {
|
|
@@ -108529,7 +108618,8 @@ ${body2}`,
|
|
|
108529
108618
|
fidelity,
|
|
108530
108619
|
resourceMaterialization,
|
|
108531
108620
|
accessIdentity,
|
|
108532
|
-
identityFallback
|
|
108621
|
+
identityFallback,
|
|
108622
|
+
access: access7
|
|
108533
108623
|
};
|
|
108534
108624
|
}
|
|
108535
108625
|
return {
|
|
@@ -108540,7 +108630,8 @@ ${body2}`,
|
|
|
108540
108630
|
fidelity,
|
|
108541
108631
|
resourceMaterialization,
|
|
108542
108632
|
accessIdentity,
|
|
108543
|
-
identityFallback
|
|
108633
|
+
identityFallback,
|
|
108634
|
+
access: access7
|
|
108544
108635
|
};
|
|
108545
108636
|
}
|
|
108546
108637
|
async function readPrefetchedLarkDocument(url, prefetched) {
|
|
@@ -108812,6 +108903,7 @@ async function validateBundle(root2, manifest) {
|
|
|
108812
108903
|
assets,
|
|
108813
108904
|
accessIdentity: manifest.access_identity,
|
|
108814
108905
|
identityFallback: false,
|
|
108906
|
+
access: report.access ?? { identity: manifest.access_identity },
|
|
108815
108907
|
...manifest.title === undefined ? {} : { title: manifest.title },
|
|
108816
108908
|
...manifest.revision_id === undefined ? {} : { revisionId: manifest.revision_id },
|
|
108817
108909
|
fidelity: report.fidelity,
|
|
@@ -109029,6 +109121,12 @@ function larkErrorRecovery(error, sourceName) {
|
|
|
109029
109121
|
next: `Inspect the Lark document shape or permissions, then rerun context run capture:lark:${sourceName}`
|
|
109030
109122
|
};
|
|
109031
109123
|
}
|
|
109124
|
+
if (/"code"\s*:\s*3380004\b/u.test(message)) {
|
|
109125
|
+
return {
|
|
109126
|
+
reasonCode: "external.authorization-required",
|
|
109127
|
+
next: `The Lark identity used for capture cannot view this document (code 3380004); signing in again does not help. Ask the document's owner to share it with that identity (for a bot, add its app as a viewer), then rerun context run capture:lark:${sourceName}`
|
|
109128
|
+
};
|
|
109129
|
+
}
|
|
109032
109130
|
if (/auth|login|permission|forbidden|unauthori[sz]ed|scope/iu.test(message)) {
|
|
109033
109131
|
return {
|
|
109034
109132
|
reasonCode: "external.authorization-required",
|
|
@@ -109183,6 +109281,13 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109183
109281
|
const previousRevision = (fingerprint === undefined ? undefined : await checkedLarkRevision(input.projectRoot, resolved.sourceName, fingerprint)) ?? previousManifest?.metadata?.source?.revisionId;
|
|
109184
109282
|
const unchangedRevisionId = !refresh && !input.prefetched && !recovery && Object.entries(input.phase.resources ?? {}).every(([key, value]) => value === DEFAULT_RESOURCE_POLICY[key]) && previousManifest?.normalizer_version === LARK_DOCUMENT_NORMALIZER_VERSION && fingerprint !== undefined ? previousRevision : undefined;
|
|
109185
109283
|
await beginFormatOnlyUpdate(input.projectRoot);
|
|
109284
|
+
let unchangedAccess;
|
|
109285
|
+
if (typeof unchangedRevisionId === "string" && previousManifest !== null) {
|
|
109286
|
+
try {
|
|
109287
|
+
unchangedAccess = readDocumentSnapshotCaptureReport({ projectRoot: input.projectRoot, materializedAt, manifest: previousManifest })?.access;
|
|
109288
|
+
} catch {}
|
|
109289
|
+
}
|
|
109290
|
+
const accessEvents = [];
|
|
109186
109291
|
let fetched;
|
|
109187
109292
|
let capturedAt = (input.now ?? new Date).toISOString();
|
|
109188
109293
|
try {
|
|
@@ -109197,21 +109302,31 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109197
109302
|
resourcePolicy: input.phase.resources,
|
|
109198
109303
|
requireCompleteBody: true,
|
|
109199
109304
|
...typeof unchangedRevisionId === "string" ? { unchangedRevisionId } : {},
|
|
109305
|
+
...unchangedAccess === undefined ? {} : { unchangedAccess },
|
|
109306
|
+
accessEvents,
|
|
109200
109307
|
...input.prefetched === undefined ? {} : { prefetched: input.prefetched }
|
|
109201
109308
|
}, input.larkRunner);
|
|
109202
109309
|
} catch (error) {
|
|
109203
|
-
|
|
109204
|
-
|
|
109310
|
+
const events = accessEvents.length ? { access_events: [...accessEvents] } : {};
|
|
109311
|
+
if (error instanceof ContextError) {
|
|
109312
|
+
if (!accessEvents.length)
|
|
109313
|
+
throw error;
|
|
109314
|
+
throw new ContextError(error.code, error.message, { ...error.detail, ...events });
|
|
109315
|
+
}
|
|
109205
109316
|
const failure2 = normalizeLarkError(error, resolved.sourceName);
|
|
109206
109317
|
if (failure2.detail?.reason_code === "external.authorization-required" || failure2.detail?.reason_code === "external.tool-failed" && error instanceof LarkCliError && error.exitCode !== 0) {
|
|
109207
|
-
throw new ContextError(failure2.code, failure2.message, { ...failure2.detail, reason_code: DOCUMENT_ACQUISITION_UNAVAILABLE, acquisition_cause: failure2.detail?.reason_code });
|
|
109318
|
+
throw new ContextError(failure2.code, failure2.message, { ...failure2.detail, ...events, reason_code: DOCUMENT_ACQUISITION_UNAVAILABLE, acquisition_cause: failure2.detail?.reason_code });
|
|
109208
109319
|
}
|
|
109209
|
-
|
|
109320
|
+
if (!accessEvents.length)
|
|
109321
|
+
throw failure2;
|
|
109322
|
+
throw new ContextError(failure2.code, failure2.message, { ...failure2.detail, ...events });
|
|
109210
109323
|
}
|
|
109324
|
+
const accessEventDetail = accessEvents.length ? { access_events: [...accessEvents] } : {};
|
|
109211
109325
|
if (fetched.fidelity.evidence_status === "error" || fetched.fidelity.projection_status === "error") {
|
|
109212
109326
|
throw new ContextError(ExitCode.WorkspaceStateError, `lark source ${resolved.sourceName} returned an incomplete body; the existing snapshot was not changed`, {
|
|
109213
109327
|
category: ErrorCategory.PartialFailure,
|
|
109214
109328
|
reason_code: DOCUMENT_ACQUISITION_UNAVAILABLE,
|
|
109329
|
+
...accessEventDetail,
|
|
109215
109330
|
sourceName: resolved.sourceName,
|
|
109216
109331
|
issues: fetched.fidelity.issues,
|
|
109217
109332
|
next: `context run ${input.phase.id} --format json`
|
|
@@ -109234,6 +109349,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109234
109349
|
},
|
|
109235
109350
|
access_identity: fetched.accessIdentity,
|
|
109236
109351
|
identity_fallback: fetched.identityFallback,
|
|
109352
|
+
access: fetched.access,
|
|
109237
109353
|
snapshot: { manifest: manifestPath, materializedAt, snapshot_hash: previousManifest.snapshot_hash, changed: false },
|
|
109238
109354
|
documents: previousManifest.files.map((file) => ({ path: file.path, title: file.title ?? resolved.sourceName, line_count: file.line_count })),
|
|
109239
109355
|
assets: previousManifest.assets ?? [],
|
|
@@ -109257,6 +109373,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109257
109373
|
throw new ContextError(ExitCode.WorkspaceStateError, "Previously captured resources were degraded; the existing snapshot was preserved. Check resource policy and access before retrying the explicit refresh.", {
|
|
109258
109374
|
category: ErrorCategory.PartialFailure,
|
|
109259
109375
|
reason_code: DOCUMENT_ACQUISITION_UNAVAILABLE,
|
|
109376
|
+
...accessEventDetail,
|
|
109260
109377
|
resources: lost.map((item) => ({ locator: item.locator, reason: item.reason })),
|
|
109261
109378
|
next_action: {
|
|
109262
109379
|
command: `context run ${input.phase.id} --input - --format json`,
|
|
@@ -109414,6 +109531,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109414
109531
|
throw new ContextError(ExitCode.WorkspaceStateError, `lark source ${resolved.sourceName} audit snapshot was preserved, but required resources could not be materialized`, {
|
|
109415
109532
|
category: ErrorCategory.PartialFailure,
|
|
109416
109533
|
code: "lark.capture.resource-materialization-failed",
|
|
109534
|
+
...accessEventDetail,
|
|
109417
109535
|
sourceName: resolved.sourceName,
|
|
109418
109536
|
snapshot: {
|
|
109419
109537
|
manifest: manifestPath,
|
|
@@ -109436,6 +109554,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109436
109554
|
},
|
|
109437
109555
|
access_identity: fetched.accessIdentity,
|
|
109438
109556
|
identity_fallback: fetched.identityFallback,
|
|
109557
|
+
access: fetched.access,
|
|
109439
109558
|
snapshot: {
|
|
109440
109559
|
manifest: manifestPath,
|
|
109441
109560
|
materializedAt,
|
|
@@ -109457,7 +109576,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109457
109576
|
diagnostics: [
|
|
109458
109577
|
...cacheDiagnostics,
|
|
109459
109578
|
...recovery === undefined ? [] : [recovery.diagnostic],
|
|
109460
|
-
...fetched.
|
|
109579
|
+
...larkAccessDiagnostics(fetched.access),
|
|
109461
109580
|
...fetched.fidelity.issues.map((issue) => `${issue.severity}: ${issue.code}: ${issue.block_type} × ${issue.count}: ${issue.reason}`),
|
|
109462
109581
|
...fetched.resourceMaterialization.items.filter((item) => item.status === "failed" || item.kind === "poll" && item.reason?.includes("absent") === true).map((item) => `${item.status}: lark.capture.resource-${item.status}: ${item.kind}: ${item.reason ?? item.locator}`),
|
|
109463
109582
|
...fetched.resourceMaterialization.items.filter((item) => item.reason_code === "document.resource.preview").map((item) => `warning: lark.capture.resource-preview: ${item.kind}: ${item.reason ?? item.locator}`),
|
|
@@ -109470,6 +109589,7 @@ async function runCaptureLarkPhase(input) {
|
|
|
109470
109589
|
return withProjectWriteLock(input.projectRoot, "capture-lark", () => runCaptureLarkPhaseUnlocked(input));
|
|
109471
109590
|
}
|
|
109472
109591
|
var init_documentCaptureLark = __esm(() => {
|
|
109592
|
+
init_larkCaptureReport();
|
|
109473
109593
|
init_src3();
|
|
109474
109594
|
init_atomicFileBatch();
|
|
109475
109595
|
init_cliFeedback();
|