@kingsoftcloud/agentkit-harness-node 0.0.0-stage → 0.0.2

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 (151) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +1 -0
  3. package/README.md +124 -2
  4. package/THIRD_PARTY_NOTICES.md +66 -0
  5. package/ZCode-LICENSE +202 -0
  6. package/dist/index.mjs +4871 -0
  7. package/dist/native-command-plan.LICENSE.txt +221 -0
  8. package/dist/native-command-plan.json +16 -0
  9. package/dist/native-command-plan.mjs +8 -0
  10. package/dist/rpc-entry.mjs +5682 -0
  11. package/package.json +169 -4
  12. package/src/native/a2a-receipt-source.mjs +19 -0
  13. package/src/native/a2a-tools.mjs +517 -0
  14. package/src/native/activity-status.mjs +30 -0
  15. package/src/native/artifact-codec.mjs +481 -0
  16. package/src/native/artifact-store.mjs +1162 -0
  17. package/src/native/assistant-stream.mjs +76 -0
  18. package/src/native/background-command-port.mjs +95 -0
  19. package/src/native/browser-action-observation.mjs +43 -0
  20. package/src/native/browser-availability.mjs +22 -0
  21. package/src/native/browser-canvas-metrics.mjs +71 -0
  22. package/src/native/browser-dom.mjs +193 -0
  23. package/src/native/browser-playwright.mjs +1249 -0
  24. package/src/native/browser-vision.mjs +369 -0
  25. package/src/native/browser-workspace-policy.mjs +22 -0
  26. package/src/native/browser-workspace-protocol.mjs +95 -0
  27. package/src/native/browser-workspace-server.mjs +164 -0
  28. package/src/native/browser-workspace.mjs +355 -0
  29. package/src/native/captured-source.mjs +3 -0
  30. package/src/native/child-budget-allocation.mjs +87 -0
  31. package/src/native/child-capabilities.mjs +35 -0
  32. package/src/native/child-command-resource.mjs +20 -0
  33. package/src/native/child-history.mjs +188 -0
  34. package/src/native/child-merge.mjs +98 -0
  35. package/src/native/child-model-surface.mjs +19 -0
  36. package/src/native/child-observation.mjs +100 -0
  37. package/src/native/child-owner.mjs +620 -0
  38. package/src/native/child-publication.mjs +76 -0
  39. package/src/native/child-readers.mjs +366 -0
  40. package/src/native/child-tools.mjs +46 -0
  41. package/src/native/child-workspace-binding.mjs +29 -0
  42. package/src/native/child-workspace-tools.mjs +1 -0
  43. package/src/native/child-workspaces.mjs +655 -0
  44. package/src/native/children.mjs +365 -0
  45. package/src/native/command-plan-worker.mjs +14 -0
  46. package/src/native/command-plan.mjs +31 -0
  47. package/src/native/command-progress.mjs +64 -0
  48. package/src/native/command-shell.mjs +9 -0
  49. package/src/native/command-workspace-observation.mjs +36 -0
  50. package/src/native/component-tools.mjs +280 -0
  51. package/src/native/context-counter.mjs +133 -0
  52. package/src/native/context-markers.mjs +51 -0
  53. package/src/native/context-profile.mjs +72 -0
  54. package/src/native/context-status.mjs +27 -0
  55. package/src/native/conversation-command-control.mjs +133 -0
  56. package/src/native/delivery-timeline.mjs +39 -0
  57. package/src/native/dsh-background-ownership.mjs +102 -0
  58. package/src/native/dsh-managed-ownership.mjs +23 -0
  59. package/src/native/dsh-turn-contract.mjs +3 -0
  60. package/src/native/dsh-turn-ownership.mjs +54 -0
  61. package/src/native/dsh-turn-runtime.mjs +498 -0
  62. package/src/native/e2b-background-supervisor.mjs +347 -0
  63. package/src/native/e2b-background.mjs +368 -0
  64. package/src/native/e2b-command-state.mjs +40 -0
  65. package/src/native/e2b-command-tools.mjs +486 -0
  66. package/src/native/e2b-sandbox-owner.mjs +227 -0
  67. package/src/native/hook-executor.mjs +249 -0
  68. package/src/native/instruction-assembly.mjs +60 -0
  69. package/src/native/instruction-context.mjs +54 -0
  70. package/src/native/local-background-supervisor.mjs +108 -0
  71. package/src/native/local-background.mjs +207 -0
  72. package/src/native/local-command-evidence.mjs +57 -0
  73. package/src/native/local-command-policy-worker.mjs +197 -0
  74. package/src/native/local-command-policy.mjs +46 -0
  75. package/src/native/local-command-state.mjs +177 -0
  76. package/src/native/local-command-tools.mjs +302 -0
  77. package/src/native/local-execution-profile.mjs +36 -0
  78. package/src/native/local-output-policy.mjs +92 -0
  79. package/src/native/local-process-bin/darwin-arm64/launcher +0 -0
  80. package/src/native/local-process-bin/darwin-x64/launcher +0 -0
  81. package/src/native/local-process-bin/linux-arm64/launcher +0 -0
  82. package/src/native/local-process-bin/linux-x64/launcher +0 -0
  83. package/src/native/local-process-launcher.c +183 -0
  84. package/src/native/local-process-licenses/GCC-COPYING.RUNTIME +72 -0
  85. package/src/native/local-process-licenses/GCC-COPYING3 +674 -0
  86. package/src/native/local-process-licenses/NOTICE +21 -0
  87. package/src/native/local-process-licenses/musl-COPYRIGHT +193 -0
  88. package/src/native/local-process-manifest.json +32 -0
  89. package/src/native/local-process.mjs +246 -0
  90. package/src/native/local-resource-profile.mjs +32 -0
  91. package/src/native/memory-candidate.mjs +121 -0
  92. package/src/native/memory-extraction-run.mjs +60 -0
  93. package/src/native/memory-extraction-tools.mjs +116 -0
  94. package/src/native/memory-recall.mjs +65 -0
  95. package/src/native/memory-store.mjs +334 -0
  96. package/src/native/memory-tools.mjs +329 -0
  97. package/src/native/model-anthropic-cache.mjs +49 -0
  98. package/src/native/model-anthropic-tool-search.mjs +85 -0
  99. package/src/native/model-anthropic.mjs +753 -0
  100. package/src/native/model-chat-usage.mjs +24 -0
  101. package/src/native/model-inline-reasoning.mjs +111 -0
  102. package/src/native/model-media.mjs +174 -0
  103. package/src/native/model-normalize.mjs +228 -0
  104. package/src/native/model-openai-chat.mjs +561 -0
  105. package/src/native/model-port.mjs +361 -0
  106. package/src/native/model-provider-compat.mjs +129 -0
  107. package/src/native/model-replay.mjs +153 -0
  108. package/src/native/model-request.mjs +15 -0
  109. package/src/native/model-responses.mjs +1205 -0
  110. package/src/native/model-sse.mjs +171 -0
  111. package/src/native/model-surface-host.mjs +27 -0
  112. package/src/native/model-tool-search-policy.mjs +16 -0
  113. package/src/native/model-transport-observation.mjs +27 -0
  114. package/src/native/owned-child.mjs +114 -0
  115. package/src/native/owned-command.mjs +106 -0
  116. package/src/native/python-syntax-worker.mjs +60 -0
  117. package/src/native/python-syntax.mjs +50 -0
  118. package/src/native/read-interruption.mjs +16 -0
  119. package/src/native/result-stream.mjs +63 -0
  120. package/src/native/ruff-ast.mjs +95 -0
  121. package/src/native/run-observation.mjs +128 -0
  122. package/src/native/session-delivery-journal.mjs +96 -0
  123. package/src/native/session-delivery.mjs +434 -0
  124. package/src/native/shell-analysis.mjs +50 -0
  125. package/src/native/skill-disclosure.mjs +404 -0
  126. package/src/native/skill-events.mjs +164 -0
  127. package/src/native/skill-tools.mjs +813 -0
  128. package/src/native/source-page.mjs +73 -0
  129. package/src/native/sqlite-session-inbox.mjs +42 -0
  130. package/src/native/sqlite-store.mjs +617 -0
  131. package/src/native/tool-authority.mjs +99 -0
  132. package/src/native/tool-guidance.mjs +12 -0
  133. package/src/native/tool-observation.mjs +75 -0
  134. package/src/native/tool-states.mjs +14 -0
  135. package/src/native/verification-authority.mjs +37 -0
  136. package/src/native/web-tools.mjs +643 -0
  137. package/src/native/workspace-checkpoints.mjs +312 -0
  138. package/src/native/workspace-context.mjs +61 -0
  139. package/src/native/workspace-display.mjs +39 -0
  140. package/src/native/workspace-edit-match.mjs +19 -0
  141. package/src/native/workspace-edit-worker.mjs +15 -0
  142. package/src/native/workspace-editing.mjs +447 -0
  143. package/src/native/workspace-image.mjs +72 -0
  144. package/src/native/workspace-instructions.mjs +107 -0
  145. package/src/native/workspace-mutation-lock.mjs +74 -0
  146. package/src/native/workspace-patch-worker.mjs +17 -0
  147. package/src/native/workspace-patch.mjs +17 -0
  148. package/src/native/workspace-paths.mjs +225 -0
  149. package/src/native/workspace-state.mjs +272 -0
  150. package/src/native/workspace-subject-observer.mjs +84 -0
  151. package/src/native/workspace-tools.mjs +1740 -0
@@ -0,0 +1,183 @@
1
+ /* Trusted POSIX exec substrate for the Node adapter. No workspace imports,
2
+ * shell parsing, policy decisions or scheduling. Build before distribution;
3
+ * never compile at install time. See local-process-manifest.json. */
4
+ #define _POSIX_C_SOURCE 200809L
5
+ #define _DARWIN_C_SOURCE 1
6
+ #define _DEFAULT_SOURCE 1
7
+ #include <errno.h>
8
+ #include <inttypes.h>
9
+ #if defined(__linux__)
10
+ #include <dirent.h>
11
+ #include <limits.h>
12
+ #endif
13
+ #include <poll.h>
14
+ #include <signal.h>
15
+ #include <stdint.h>
16
+ #include <stdio.h>
17
+ #include <stdlib.h>
18
+ #include <string.h>
19
+ #include <sys/resource.h>
20
+ #include <sys/types.h>
21
+ #include <unistd.h>
22
+
23
+ #define CONTRACT "agentkit.local-process-control/v1"
24
+ #define MAX_EXACT UINT64_C(9007199254740991)
25
+ struct limit { const char *name; int resource; uint64_t requested; rlim_t effective; int status; };
26
+ static int number(const char *text, uint64_t *value) {
27
+ if (!text || !*text || *text == '0') return -1;
28
+ uint64_t n = 0;
29
+ for (const unsigned char *p = (const unsigned char *)text; *p; ++p) {
30
+ if (*p < '0' || *p > '9' || n > (MAX_EXACT - (*p - '0')) / 10) return -1;
31
+ n = n * 10 + (*p - '0');
32
+ }
33
+ *value = n; return 0;
34
+ }
35
+ static int write_all(int fd, const char *text, size_t length) {
36
+ while (length) {
37
+ ssize_t n = write(fd, text, length);
38
+ if (n < 0 && errno == EINTR) continue;
39
+ if (n <= 0) return -1;
40
+ text += n; length -= (size_t)n;
41
+ }
42
+ return 0;
43
+ }
44
+ #if defined(__linux__)
45
+ /* RLIMIT_NPROC is scoped to the real user on Linux, so a shared runner can
46
+ * already be at the requested limit before this command starts. Count only
47
+ * this process group instead; the watcher itself is excluded from the cap. */
48
+ static int group_processes(pid_t group) {
49
+ DIR *directory = opendir("/proc");
50
+ if (!directory) return -1;
51
+ int count = 0;
52
+ struct dirent *entry;
53
+ while ((entry = readdir(directory)) != NULL) {
54
+ char *end = NULL;
55
+ errno = 0;
56
+ long number = strtol(entry->d_name, &end, 10);
57
+ if (errno || end == entry->d_name || *end || number < 1 || number > INT_MAX) continue;
58
+ char path[64];
59
+ int length = snprintf(path, sizeof path, "/proc/%ld/stat", number);
60
+ if (length <= 0 || (size_t)length >= sizeof path) continue;
61
+ FILE *file = fopen(path, "r");
62
+ if (!file) continue;
63
+ char line[4096];
64
+ if (fgets(line, sizeof line, file)) {
65
+ char *closing = strrchr(line, ')');
66
+ char state;
67
+ long parent = 0, process_group = 0;
68
+ if (closing && sscanf(closing + 1, " %c %ld %ld", &state, &parent, &process_group) == 3
69
+ && (pid_t)process_group == group) count++;
70
+ }
71
+ fclose(file);
72
+ }
73
+ closedir(directory);
74
+ return count;
75
+ }
76
+ #endif
77
+ static void watch_owner(int owner, int report, pid_t group, uint64_t max_processes) {
78
+ #if !defined(__linux__)
79
+ (void)max_processes;
80
+ #endif
81
+ close(report);
82
+ close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO);
83
+ /* Hold the owned group through the caller's TERM->KILL cleanup window. */
84
+ signal(SIGTERM, SIG_IGN);
85
+ char byte;
86
+ for (;;) {
87
+ #if defined(__linux__)
88
+ int count = group_processes(group);
89
+ if (count < 0 || (count > 1 && (uint64_t)(count - 1) > max_processes)) {
90
+ kill(-group, SIGKILL);
91
+ _exit(0);
92
+ }
93
+ struct pollfd item = { .fd = owner, .events = POLLIN | POLLHUP };
94
+ int ready = poll(&item, 1, 100);
95
+ if (ready < 0 && errno == EINTR) continue;
96
+ if (ready < 0) break;
97
+ if (ready == 0) continue;
98
+ #else
99
+ ssize_t n = read(owner, &byte, 1);
100
+ #endif
101
+ #if defined(__linux__)
102
+ ssize_t n = read(owner, &byte, 1);
103
+ #endif
104
+ if (n > 0) continue;
105
+ if (n < 0 && errno == EINTR) continue;
106
+ if (n < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
107
+ struct pollfd item = { .fd = owner, .events = POLLIN | POLLHUP };
108
+ if (poll(&item, 1, -1) < 0 && errno != EINTR) break;
109
+ continue;
110
+ }
111
+ break;
112
+ }
113
+ kill(-group, SIGKILL);
114
+ _exit(0);
115
+ }
116
+ int main(int argc, char **argv) {
117
+ /* cpu, address bytes, process count, open files, file bytes, report fd,
118
+ * owner fd, --, executable, ... . All numbers are strict decimal data. */
119
+ if (argc < 10 || strcmp(argv[8], "--") != 0) return 125;
120
+ uint64_t values[7];
121
+ for (int i = 0; i < 7; ++i) if (number(argv[i + 1], &values[i]) < 0) return 125;
122
+ if (values[5] < 3 || values[5] > 1024 || values[6] < 3 || values[6] > 1024 || values[5] == values[6]) return 125;
123
+ int report = (int)values[5], owner = (int)values[6];
124
+ if (getpgrp() != getpid()) return 125;
125
+ signal(SIGPIPE, SIG_IGN);
126
+ struct limit limits[5] = {
127
+ { "cpuSeconds", RLIMIT_CPU, values[0], 0, 0 },
128
+ { "addressSpaceBytes", RLIMIT_AS, values[1], 0, 0 },
129
+ { "maxProcesses", RLIMIT_NPROC, values[2], 0, 0 },
130
+ { "maxOpenFiles", RLIMIT_NOFILE, values[3], 0, 0 },
131
+ { "maxFileBytes", RLIMIT_FSIZE, values[4], 0, 0 },
132
+ };
133
+ /* Fork the owner watchdog before applying the child resource limits.
134
+ * On Linux its process-group counter replaces RLIMIT_NPROC, whose
135
+ * per-user scope is unsafe on shared runners. */
136
+ pid_t group = getpgrp();
137
+ pid_t watcher = fork();
138
+ if (watcher == 0) watch_owner(owner, report, group, values[2]);
139
+ int failed = watcher < 0, unsupported = 0;
140
+ for (int i = 0; i < 5; ++i) {
141
+ struct limit *item = &limits[i];
142
+ #if defined(__APPLE__)
143
+ /* Match the reference's declared Darwin exceptions exactly. */
144
+ if (i == 1 || i == 2) { item->status = 2; unsupported++; continue; }
145
+ #elif defined(__linux__)
146
+ /* RLIMIT_NPROC is per-user and cannot safely cap one command on a
147
+ * shared host. The owner watchdog enforces a process-group bound. */
148
+ if (i == 2) { item->effective = item->requested; item->status = 0; continue; }
149
+ #endif
150
+ struct rlimit before, after;
151
+ if (getrlimit(item->resource, &before) < 0) { item->status = 1; failed++; continue; }
152
+ item->effective = (rlim_t)item->requested;
153
+ if ((uint64_t)item->effective != item->requested) { item->status = 1; failed++; continue; }
154
+ if (before.rlim_max != RLIM_INFINITY && before.rlim_max < item->effective) item->effective = before.rlim_max;
155
+ struct rlimit desired = { .rlim_cur = item->effective, .rlim_max = item->effective };
156
+ if (setrlimit(item->resource, &desired) < 0 || getrlimit(item->resource, &after) < 0
157
+ || after.rlim_cur != item->effective || after.rlim_max != item->effective) { item->status = 1; failed++; }
158
+ }
159
+ char buffer[4096];
160
+ int at = snprintf(buffer, sizeof buffer, "{\"schemaVersion\":\"%s\",\"status\":\"%s\",\"watcherPid\":%ld,\"applied\":{",
161
+ CONTRACT, failed ? "failed" : unsupported ? "partial" : "applied", (long)watcher);
162
+ int count = 0;
163
+ for (int i = 0; i < 5; ++i) if (limits[i].status == 0)
164
+ at += snprintf(buffer + at, sizeof buffer - (size_t)at, "%s\"%s\":%" PRIu64,
165
+ count++ ? "," : "", limits[i].name, (uint64_t)limits[i].effective);
166
+ at += snprintf(buffer + at, sizeof buffer - (size_t)at, "},\"unsupported\":["); count = 0;
167
+ for (int i = 0; i < 5; ++i) if (limits[i].status == 2)
168
+ at += snprintf(buffer + at, sizeof buffer - (size_t)at, "%s\"%s\"", count++ ? "," : "", limits[i].name);
169
+ at += snprintf(buffer + at, sizeof buffer - (size_t)at, "],\"failed\":["); count = 0;
170
+ for (int i = 0; i < 5; ++i) if (limits[i].status == 1)
171
+ at += snprintf(buffer + at, sizeof buffer - (size_t)at, "%s\"%s\"", count++ ? "," : "", limits[i].name);
172
+ if (watcher < 0 && !count && failed) at += snprintf(buffer + at, sizeof buffer - (size_t)at, "\"owner_watchdog\"");
173
+ at += snprintf(buffer + at, sizeof buffer - (size_t)at, "]}\n");
174
+ if (at <= 0 || (size_t)at >= sizeof buffer || write_all(report, buffer, (size_t)at) < 0) return 125;
175
+ close(report); close(owner);
176
+ if (failed) return 125;
177
+ /* SIGPIPE was changed only for the trusted report write. Restore default
178
+ * before executing a program; its own signal behavior remains its choice. */
179
+ signal(SIGPIPE, SIG_DFL);
180
+ execvp(argv[9], &argv[9]);
181
+ fputs("local-process launcher exec failed\n", stderr);
182
+ return 126;
183
+ }
@@ -0,0 +1,72 @@
1
+ GCC RUNTIME LIBRARY EXCEPTION
2
+
3
+ Version 3.1, 31 March 2009
4
+
5
+ Copyright (C) 2009 Free Software Foundation, Inc. <http://fsf.org/>
6
+
7
+ Everyone is permitted to copy and distribute verbatim copies of this
8
+ license document, but changing it is not allowed.
9
+
10
+ This GCC Runtime Library Exception ("Exception") is an additional
11
+ permission under section 7 of the GNU General Public License, version
12
+ 3 ("GPLv3"). It applies to a given file (the "Runtime Library") that
13
+ bears a notice placed by the copyright holder of the file stating that
14
+ the file is governed by GPLv3 along with this Exception.
15
+
16
+ When you use GCC to compile a program, GCC may combine portions of
17
+ certain GCC header files and runtime libraries with the compiled
18
+ program. The purpose of this Exception is to allow compilation of
19
+ non-GPL (including proprietary) programs to use, in this way, the
20
+ header files and runtime libraries covered by this Exception.
21
+
22
+ 0. Definitions.
23
+
24
+ A file is an "Independent Module" if it either requires the Runtime
25
+ Library for execution after a Compilation Process, or makes use of an
26
+ interface provided by the Runtime Library, but is not otherwise based
27
+ on the Runtime Library.
28
+
29
+ "GCC" means a version of the GNU Compiler Collection, with or without
30
+ modifications, governed by version 3 (or a specified later version) of
31
+ the GNU General Public License (GPL) with the option of using any
32
+ subsequent versions published by the FSF.
33
+
34
+ "GPL-compatible Software" is software whose conditions of propagation,
35
+ modification and use would permit combination with GCC in accord with
36
+ the license of GCC.
37
+
38
+ "Target Code" refers to output from any compiler for a real or virtual
39
+ target processor architecture, in executable form or suitable for
40
+ input to an assembler, loader, linker and/or execution
41
+ phase. Notwithstanding that, Target Code does not include data in any
42
+ format that is used as a compiler intermediate representation, or used
43
+ for producing a compiler intermediate representation.
44
+
45
+ The "Compilation Process" transforms code entirely represented in
46
+ non-intermediate languages designed for human-written code, and/or in
47
+ Java Virtual Machine byte code, into Target Code. Thus, for example,
48
+ use of source code generators and preprocessors need not be considered
49
+ part of the Compilation Process, since the Compilation Process can be
50
+ understood as starting with the output of the generators or
51
+ preprocessors.
52
+
53
+ A Compilation Process is "Eligible" if it is done using GCC, alone or
54
+ with other GPL-compatible software, or if it is done without using any
55
+ work based on GCC. For example, using non-GPL-compatible Software to
56
+ optimize any GCC intermediate representations would not qualify as an
57
+ Eligible Compilation Process.
58
+
59
+ 1. Grant of Additional Permission.
60
+
61
+ You have permission to propagate a work of Target Code formed by
62
+ combining the Runtime Library with Independent Modules, even if such
63
+ propagation would otherwise violate the terms of GPLv3, provided that
64
+ all Target Code was generated by Eligible Compilation Processes. You
65
+ may then convey such a combination under terms of your choice,
66
+ consistent with the licensing of the Independent Modules.
67
+
68
+ 2. No Weakening of GCC Copyleft.
69
+
70
+ The availability of this Exception does not imply any general
71
+ presumption that third-party software is unaffected by the copyleft
72
+ requirements of the license of GCC.