@zq-silk/yui 0.15.8 → 0.15.9

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.
Files changed (74) hide show
  1. package/ARCHITECTURE.md +2 -0
  2. package/ARCHITECTURE.zh-CN.md +151 -0
  3. package/README.md +211 -14
  4. package/dist/artifacts/artifactCapability.js +74 -0
  5. package/dist/artifacts/artifactCommitLock.js +249 -0
  6. package/dist/artifacts/artifactPaths.js +151 -0
  7. package/dist/artifacts/gitArtifactRef.js +146 -0
  8. package/dist/artifacts/managedGit.js +332 -0
  9. package/dist/artifacts/taskArtifactRepository.js +277 -0
  10. package/dist/cli/commandCatalog.js +14 -10
  11. package/dist/cli.js +67 -0
  12. package/dist/commands/operatorCommands.js +33 -2
  13. package/dist/commands/taskActivationCommands.js +22 -0
  14. package/dist/commands/taskCommands.js +342 -79
  15. package/dist/context/runContextPack.js +28 -16
  16. package/dist/context/taskContext.js +26 -3
  17. package/dist/controller/controller.js +8 -2
  18. package/dist/kernel/builtinCapabilities.js +32 -24
  19. package/dist/message/message.js +56 -0
  20. package/dist/plugins/pluginService.js +11 -3
  21. package/dist/resources/projectResource.js +0 -48
  22. package/dist/resources/projectResourceService.js +3 -81
  23. package/dist/setup/setupCommand.js +3 -8
  24. package/dist/storage/migrations/artifactsToGit.js +338 -0
  25. package/dist/storage/migrations/submitIntent.js +126 -0
  26. package/dist/storage/sqliteSchema.js +37 -3
  27. package/dist/storage/sqliteStore.js +1 -21
  28. package/dist/storage/storageVersions.js +1 -1
  29. package/dist/storage/storeRpc.js +1 -1
  30. package/dist/task/taskActivation.js +26 -0
  31. package/dist/task/taskActivationService.js +85 -69
  32. package/dist/task/taskSubmission.js +236 -0
  33. package/dist/web/assets/client/app.js +3 -2
  34. package/dist/web/assets/client/taskSurface.js +96 -7
  35. package/dist/web/webServer.js +18 -3
  36. package/dist/web/webTaskSurface.js +6 -6
  37. package/dist/workItem/workItem.js +14 -10
  38. package/docs/agent-result-consumption.md +2 -0
  39. package/docs/agent-result-consumption.zh-CN.md +81 -0
  40. package/docs/agent-runtime-drivers.md +2 -0
  41. package/docs/agent-runtime-drivers.zh-CN.md +77 -0
  42. package/docs/architecture/README.md +44 -32
  43. package/docs/architecture/README.zh-CN.md +43 -0
  44. package/docs/architecture/capabilities-and-resources.md +118 -79
  45. package/docs/architecture/capabilities-and-resources.zh-CN.md +83 -0
  46. package/docs/managed-turn-and-session-runtime.md +2 -0
  47. package/docs/managed-turn-and-session-runtime.zh-CN.md +180 -0
  48. package/docs/observability/README.md +2 -0
  49. package/docs/observability/README.zh-CN.md +71 -0
  50. package/docs/plugin-sdk.md +320 -217
  51. package/docs/plugin-sdk.zh-CN.md +293 -0
  52. package/docs/provider-runtime.md +2 -0
  53. package/docs/provider-runtime.zh-CN.md +132 -0
  54. package/docs/release-workflow.md +2 -0
  55. package/docs/release-workflow.zh-CN.md +237 -0
  56. package/docs/roles-and-configuration.md +2 -0
  57. package/docs/roles-and-configuration.zh-CN.md +96 -0
  58. package/docs/sqlite-control-plane-design.md +2 -0
  59. package/docs/sqlite-control-plane-design.zh-CN.md +62 -0
  60. package/docs/task-dag-semantics.md +80 -57
  61. package/docs/task-dag-semantics.zh-CN.md +59 -0
  62. package/docs/task-delivery.md +2 -0
  63. package/docs/task-delivery.zh-CN.md +82 -0
  64. package/docs/task-local-identity.md +2 -0
  65. package/docs/task-local-identity.zh-CN.md +58 -0
  66. package/docs/testing/verification-levels.md +2 -0
  67. package/docs/testing/verification-levels.zh-CN.md +69 -0
  68. package/i18n/README.zh-CN.md +199 -10
  69. package/package.json +2 -1
  70. package/skills/yui-leader/SKILL.md +88 -331
  71. package/skills/yui-leader/references/execution.md +303 -0
  72. package/skills/yui-leader/references/planning.md +109 -0
  73. package/skills/yui-leader/references/task-plugins.md +8 -4
  74. package/skills/yui-operator/SKILL.md +16 -3
package/dist/cli.js CHANGED
@@ -46,6 +46,7 @@ import { runTaskPublicationVerifyCommand } from "./commands/taskPublicationVerif
46
46
  import { createGitHubCliPublicationVerifier } from "./external/githubPublicationVerifier.js";
47
47
  import { createGitLabCliPublicationVerifier } from "./external/gitlabPublicationVerifier.js";
48
48
  import { taskLocalActor, assertTaskDeliveryAuthority } from "./commands/taskActor.js";
49
+ import { saveArtifactCapability, readArtifactCapability, listArtifactsCapability } from "./artifacts/artifactCapability.js";
49
50
  import { parseTaskExecutionStartRequest, parseTaskExecutionStopRequest, finalizeStoppedTaskExecution, startTaskExecutionCommand, stopTaskExecutionCommand } from "./commands/taskExecutionCommands.js";
50
51
  import { runTaskIntegrationCommand } from "./commands/taskIntegrationCommands.js";
51
52
  import { runTaskChangeSetCommand } from "./commands/taskChangeSetCommands.js";
@@ -773,6 +774,72 @@ export async function main() {
773
774
  return;
774
775
  }
775
776
  if (resolved[0] === "task") {
777
+ if (resolved[1] === "artifact") {
778
+ // File/directory artifacts live in the Task's local Git repository, so
779
+ // their save/read/list are asynchronous and handled here rather than in
780
+ // the synchronous runTaskCommand chain. Save commits exactly one path and
781
+ // returns a self-certifying commit-pinned reference; read pins to a commit
782
+ // for frozen evidence; list is an ordinary current read.
783
+ const action = resolved[2];
784
+ const taskId = resolved[3];
785
+ const usage = "Usage: yui task artifact list <task> | read <task> <relative-path> [<commit>] | "
786
+ + "save <task> <relative-path> <content> [--message <text>] [--expected-head <commit>]";
787
+ if (taskId === undefined || action === undefined || !["list", "read", "save"].includes(action)) {
788
+ throw usageError(usage);
789
+ }
790
+ if (process.env.YUI_SESSION_SCOPE === "task" && process.env.YUI_TASK_ID !== taskId) {
791
+ throw usageError("Artifact is outside the managed Task scope.");
792
+ }
793
+ if (store.getTask(taskId) === null)
794
+ throw usageError(`Task not found: ${taskId}.`);
795
+ let data;
796
+ if (action === "list") {
797
+ if (resolved.length !== 4)
798
+ throw usageError(usage);
799
+ data = await listArtifactsCapability(home, taskId);
800
+ }
801
+ else if (action === "read") {
802
+ const relativePath = resolved[4];
803
+ const commit = resolved[5];
804
+ if (relativePath === undefined || resolved.length > 6)
805
+ throw usageError(usage);
806
+ data = await readArtifactCapability(home, taskId, {
807
+ relativePath, ...(commit === undefined ? {} : { commit })
808
+ });
809
+ }
810
+ else {
811
+ // save: a delivery-authoritative action; a managed Task caller must be the current Leader.
812
+ taskLocalActor(store, process.env, taskId);
813
+ const relativePath = resolved[4];
814
+ const content = resolved[5];
815
+ if (relativePath === undefined || content === undefined)
816
+ throw usageError(usage);
817
+ const rest = resolved.slice(6);
818
+ let message;
819
+ let expectedHead;
820
+ for (let index = 0; index < rest.length; index += 1) {
821
+ const value = rest[index + 1];
822
+ if (rest[index] === "--message" && value !== undefined) {
823
+ message = value;
824
+ index += 1;
825
+ continue;
826
+ }
827
+ if (rest[index] === "--expected-head" && value !== undefined) {
828
+ expectedHead = value;
829
+ index += 1;
830
+ continue;
831
+ }
832
+ throw usageError(usage);
833
+ }
834
+ data = await saveArtifactCapability(home, taskId, {
835
+ relativePath, content,
836
+ ...(message === undefined ? {} : { message }),
837
+ ...(expectedHead === undefined ? {} : { expectedHead })
838
+ });
839
+ }
840
+ emit(JSON.stringify(data, null, 2), false, data);
841
+ return;
842
+ }
776
843
  if (resolved[1] === "execution") {
777
844
  if (resolved[2] === "stop") {
778
845
  const request = parseTaskExecutionStopRequest(resolved.slice(3));
@@ -5,6 +5,7 @@ import { listOperatorSessions, projectOperatorStatus, prepareOperatorNewSession,
5
5
  import { defaultTableWidth, renderTable } from "../output/table.js";
6
6
  import { formatRelativeTimestamp } from "../output/timePresentation.js";
7
7
  import { updateGlobalRole } from "../role/role.js";
8
+ import { TASK_SUBMISSION_INTENTS } from "../message/message.js";
8
9
  import { submitOperatorMessage } from "./taskCommands.js";
9
10
  import { readCommandText } from "./textInput.js";
10
11
  /** Operator command parsing never launches or attaches a native process. */
@@ -63,10 +64,12 @@ function status(args, store, options) {
63
64
  };
64
65
  }
65
66
  function submit(rest, store, options) {
66
- const usage = "Operator submit usage: yui operator submit (<body>|--body-file <path|->) [--task <id>].";
67
+ const usage = "Operator submit usage: yui operator submit (<body>|--body-file <path|->) [--task <id>] [--intent record|discuss|develop] [--request-id <key>].";
67
68
  const positionals = [];
68
69
  let taskId;
69
70
  let bodyFile;
71
+ let intentRaw;
72
+ let requestId;
70
73
  for (let index = 0; index < rest.length; index += 1) {
71
74
  const value = rest[index];
72
75
  if (value === "--body-file") {
@@ -79,6 +82,26 @@ function submit(rest, store, options) {
79
82
  index += 1;
80
83
  continue;
81
84
  }
85
+ if (value === "--intent") {
86
+ if (intentRaw !== undefined)
87
+ throw usageError("Option may only be specified once: --intent.", usage);
88
+ const candidate = rest[index + 1];
89
+ if (candidate === undefined || candidate.startsWith("--"))
90
+ throw usageError("--intent is required.", usage);
91
+ intentRaw = candidate.trim();
92
+ index += 1;
93
+ continue;
94
+ }
95
+ if (value === "--request-id") {
96
+ if (requestId !== undefined)
97
+ throw usageError("Option may only be specified once: --request-id.", usage);
98
+ const candidate = rest[index + 1];
99
+ if (candidate === undefined || candidate.startsWith("--"))
100
+ throw usageError("--request-id is required.", usage);
101
+ requestId = candidate.trim();
102
+ index += 1;
103
+ continue;
104
+ }
82
105
  if (value !== "--task") {
83
106
  if (value.startsWith("--"))
84
107
  throw usageError(`Unsupported option: ${value}.`, usage);
@@ -96,10 +119,18 @@ function submit(rest, store, options) {
96
119
  }
97
120
  if (positionals.length > 1)
98
121
  throw usageError(usage);
122
+ const intent = intentRaw === undefined
123
+ ? undefined
124
+ : TASK_SUBMISSION_INTENTS.includes(intentRaw)
125
+ ? intentRaw
126
+ : (() => { throw usageError(`--intent must be one of ${TASK_SUBMISSION_INTENTS.join(", ")}: ${intentRaw}.`, usage); })();
127
+ if (requestId !== undefined && requestId.length === 0) {
128
+ throw usageError("--request-id is required.", usage);
129
+ }
99
130
  const body = readCommandText(positionals[0], bodyFile, "--body", usage);
100
131
  return {
101
132
  kind: "output",
102
- output: submitOperatorMessage(body, taskId, store, options)
133
+ output: submitOperatorMessage(body, taskId, store, options, intent, requestId)
103
134
  };
104
135
  }
105
136
  function listSessions(args, store, options) {
@@ -52,6 +52,10 @@ function requestActivation(args, store, options) {
52
52
  actorId: caller.actorId,
53
53
  authorityRef: caller.authorityRef,
54
54
  environmentPlan,
55
+ // The activation-request command is the explicit activation boundary, so
56
+ // every request it records carries an explicit provable origin (task-32
57
+ // §2.4). A develop submission records its own request with `submit-develop`.
58
+ origin: "explicit",
55
59
  ...(caller.planningRunId === undefined ? {} : { callerRunId: caller.planningRunId })
56
60
  }, now));
57
61
  // An immediate request has nothing left to wait for, so ask the Controller to
@@ -173,6 +177,24 @@ function activationCaller(store, options, taskId) {
173
177
  : {})
174
178
  };
175
179
  }
180
+ if (actor === "operator") {
181
+ return nonLeaderActivationIdentity(store, "operator");
182
+ }
183
+ return nonLeaderActivationIdentity(store, "user");
184
+ }
185
+ /**
186
+ * The activation actor/authority identity for a user or Operator submission.
187
+ *
188
+ * A develop submission (task-32 §2.4) records its own activation request inside
189
+ * the message-save transaction, and it must stamp the exact same identity the
190
+ * explicit `yui task activation request` boundary would for the same caller —
191
+ * otherwise the Controller and the workspace preparer could treat "the user
192
+ * asked via submit" differently from "the user asked via activate". Sharing this
193
+ * mapping is what keeps the two entry points one activation contract rather than
194
+ * two. Leader identity is deliberately excluded: it binds to a live native
195
+ * Session and is resolved only by {@link activationCaller}.
196
+ */
197
+ export function nonLeaderActivationIdentity(store, actor) {
176
198
  if (actor === "operator") {
177
199
  return {
178
200
  actorId: "global:operator",