@gyoungwe/research-suite 0.1.6 → 0.1.7

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.
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "version": 1,
3
3
  "generator": "packages/research-suite/scripts/build.mjs",
4
- "packageVersion": "0.1.6",
4
+ "packageVersion": "0.1.7",
5
5
  "bundled": [
6
6
  "@gyoungwe/pi-core",
7
7
  "@gyoungwe/pi-knowledge",
8
8
  "@gyoungwe/pi-research"
9
9
  ],
10
- "dependenciesSha256": "5db2cbef3b8c1eeec34b7e1d16766aaa7025912dbb19cb040dfdb0c167afdab5"
10
+ "dependenciesSha256": "97dd221032721bdfabd9c582ad0cf6255e8954d7ed4306e0f557ce0051cd7d5e"
11
11
  }
@@ -3,6 +3,6 @@
3
3
  "generator": "scripts/build-pi-core.mjs",
4
4
  "inputsSha256": "a912656013c014410f9ef484f717ce4d4c71a9301b619df43ab5eec93441a4c1",
5
5
  "outputs": {
6
- "dist/index.mjs": "9e1750ae74732ec35ce2ab0496d26180b308a312b7a7e5479c81d5a2fb59a736"
6
+ "dist/index.mjs": "5ac615aa70faa7996b8f6d8519afcb6662f7f65786042993e317ef83ff571f7b"
7
7
  }
8
8
  }
@@ -20,6 +20,8 @@ import { AsyncLocalStorage } from "node:async_hooks";
20
20
  var contexts = new AsyncLocalStorage();
21
21
  var installedRuntime = null;
22
22
  var standaloneRuntime = null;
23
+ var runtimeBindings = /* @__PURE__ */ new WeakSet();
24
+ var hostRuntimes = /* @__PURE__ */ new WeakMap();
23
25
  var KeyedScheduler = class {
24
26
  #tails = /* @__PURE__ */ new Map();
25
27
  #disposed = false;
@@ -100,6 +102,99 @@ function createStandaloneRuntime(log = {}) {
100
102
  };
101
103
  return runtime;
102
104
  }
105
+ function bindRuntime(pi) {
106
+ if (!pi || typeof pi !== "object" && typeof pi !== "function") return () => {
107
+ };
108
+ if (runtimeBindings.has(pi)) return () => {
109
+ };
110
+ runtimeBindings.add(pi);
111
+ const inherited = currentRuntime();
112
+ const fallback = createStandaloneRuntime();
113
+ adoptRuntimeState(inherited, fallback);
114
+ hostRuntimes.set(pi, fallback);
115
+ if (!pi.events?.on || !pi.events?.emit) {
116
+ return () => {
117
+ if (hostRuntimes.get(pi) !== fallback) return;
118
+ runtimeBindings.delete(pi);
119
+ hostRuntimes.delete(pi);
120
+ void fallback.dispose();
121
+ };
122
+ }
123
+ const receive = (payload) => {
124
+ if (!payload || typeof payload !== "object") return;
125
+ const event = payload;
126
+ if (event.version !== RUNTIME_BRIDGE_VERSION) return;
127
+ const runtime = event.runtime;
128
+ if (!runtime || typeof runtime !== "object" || !runtime.scheduler) return;
129
+ const previous = hostRuntimes.get(pi);
130
+ if (previous && previous !== runtime) adoptRuntimeState(previous, runtime);
131
+ hostRuntimes.set(pi, runtime);
132
+ if (previous && previous !== runtime) void previous.dispose();
133
+ };
134
+ pi.events.on("drone:runtime/v1", receive);
135
+ void pi.events.emit?.("drone:runtime/request/v1", { version: RUNTIME_BRIDGE_VERSION });
136
+ return () => {
137
+ runtimeBindings.delete(pi);
138
+ if (hostRuntimes.get(pi) === fallback) {
139
+ hostRuntimes.delete(pi);
140
+ void fallback.dispose();
141
+ } else hostRuntimes.delete(pi);
142
+ };
143
+ }
144
+ function adoptRuntimeState(previous, runtime) {
145
+ const sourceTools = previous?.tools?.manifest;
146
+ if (sourceTools) {
147
+ if (!runtime.tools) runtime.tools = {};
148
+ const targetTools = runtime.tools.manifest ?? { tools: /* @__PURE__ */ new Map(), families: /* @__PURE__ */ new Map() };
149
+ runtime.tools.manifest = targetTools;
150
+ if (!targetTools.tools) targetTools.tools = /* @__PURE__ */ new Map();
151
+ for (const [name, meta] of sourceTools.tools || []) {
152
+ if (!targetTools.tools.has(name)) targetTools.tools.set(name, meta);
153
+ }
154
+ if (!targetTools.families) targetTools.families = /* @__PURE__ */ new Map();
155
+ for (const [name, meta] of sourceTools.families || []) {
156
+ if (!targetTools.families.has(name)) targetTools.families.set(name, meta);
157
+ }
158
+ }
159
+ const sourceAcceptance = previous?.tasks?.acceptance;
160
+ if (sourceAcceptance) {
161
+ if (!runtime.tasks) runtime.tasks = {};
162
+ const targetAcceptance = runtime.tasks.acceptance ?? {
163
+ verifiers: /* @__PURE__ */ new Map(),
164
+ kinds: [],
165
+ properties: {}
166
+ };
167
+ runtime.tasks.acceptance = targetAcceptance;
168
+ if (!targetAcceptance.verifiers) targetAcceptance.verifiers = /* @__PURE__ */ new Map();
169
+ for (const [kind, verifier] of sourceAcceptance.verifiers || []) {
170
+ if (!targetAcceptance.verifiers.has(kind)) targetAcceptance.verifiers.set(kind, verifier);
171
+ }
172
+ if (Array.isArray(sourceAcceptance.kinds)) {
173
+ targetAcceptance.kinds ??= [];
174
+ for (const kind of sourceAcceptance.kinds)
175
+ if (!targetAcceptance.kinds.includes(kind)) targetAcceptance.kinds.push(kind);
176
+ }
177
+ targetAcceptance.properties ??= {};
178
+ for (const [key, value] of Object.entries(sourceAcceptance.properties || {}))
179
+ if (!(key in targetAcceptance.properties)) targetAcceptance.properties[key] = value;
180
+ }
181
+ for (const domain of ["knowledge", "tasks", "tools"]) {
182
+ const source = previous?.[domain];
183
+ if (!source || typeof source !== "object") continue;
184
+ let target = runtime[domain];
185
+ if (!target) {
186
+ target = {};
187
+ runtime[domain] = target;
188
+ }
189
+ for (const key of Reflect.ownKeys(source)) {
190
+ if (domain === "tasks" && key === "workbench") continue;
191
+ if (!(key in target)) target[key] = source[key];
192
+ }
193
+ }
194
+ }
195
+ function runtimeForHost(pi) {
196
+ return hostRuntimes.get(pi) ?? currentRuntime();
197
+ }
103
198
  function currentRuntime() {
104
199
  const scoped = contexts.getStore();
105
200
  if (scoped) return scoped;
@@ -147,6 +242,7 @@ function runtimeSlot(domain, slot, create) {
147
242
  );
148
243
  return proxy;
149
244
  }
245
+ var RUNTIME_BRIDGE_VERSION = 1;
150
246
 
151
247
  // ../tasks/src/runtime-compiled/acceptance.mjs
152
248
  var CORE_ACCEPTANCE_KINDS = Object.freeze(["file", "human_review"]);
@@ -1970,7 +2066,7 @@ function shouldAskToContinue(task2) {
1970
2066
 
1971
2067
  // ../tasks/src/runtime-compiled/register.mjs
1972
2068
  function registerWorkbench(pi, options = {}) {
1973
- let context, activeSessionId, prepared = false, awaitingUser = false, halted = false;
2069
+ let context, activeSessionId, prepared = false, awaitingUser = false, halted = false, readKnowledgeBinding = options.readKnowledgeBinding || (() => pi?.drone?.readKnowledgeBinding?.() || null);
1974
2070
  let pendingStatus = null;
1975
2071
  let providerTurnOpen = false;
1976
2072
  const authorize = async (cwd, path) => {
@@ -2045,7 +2141,9 @@ function registerWorkbench(pi, options = {}) {
2045
2141
  journal.attach(scope, ctx.sessionManager?.getBranch?.() || [], force);
2046
2142
  evidence.attach(scope, journal.snapshot()?.id, ctx.sessionManager?.getBranch?.() || [], force);
2047
2143
  };
2048
- const readKnowledgeBinding = options.readKnowledgeBinding || (() => pi?.drone?.readKnowledgeBinding?.() || null);
2144
+ journal.configure = (nextOptions = {}) => {
2145
+ if (nextOptions.readKnowledgeBinding) readKnowledgeBinding = nextOptions.readKnowledgeBinding;
2146
+ };
2049
2147
  const bindingKey = async () => {
2050
2148
  const b = await readKnowledgeBinding();
2051
2149
  return b ? `${b.vaultId}:${b.revision}` : null;
@@ -2745,7 +2843,73 @@ function createTaskJournal({ persist = () => {
2745
2843
  };
2746
2844
  }
2747
2845
  function registerTaskRuntime(pi, options = {}) {
2748
- if (process.env.DRONE_TASK_WORKBENCH !== "off") return registerWorkbench(pi, options);
2846
+ bindRuntime(pi);
2847
+ const hostRuntime = runtimeForHost(pi);
2848
+ hostRuntime.tasks ??= {};
2849
+ if (hostRuntime.tasks.workbench?.journal) {
2850
+ hostRuntime.tasks.workbench.journal.configure?.(options);
2851
+ return hostRuntime.tasks.workbench.journal;
2852
+ }
2853
+ const shared = requestSharedTaskRuntime(pi);
2854
+ if (shared?.journal) {
2855
+ shared.journal.configure?.(options);
2856
+ hostRuntime.tasks.workbench = shared;
2857
+ return shared.journal;
2858
+ }
2859
+ const registry3 = taskRuntimeRegistry(pi);
2860
+ if (registry3?.journal) {
2861
+ registry3.journal.configure?.(options);
2862
+ return registry3.journal;
2863
+ }
2864
+ const journal = process.env.DRONE_TASK_WORKBENCH !== "off" ? registerWorkbench(pi, options) : createLegacyTaskJournal(pi);
2865
+ if (registry3) registry3.journal = journal;
2866
+ hostRuntime.tasks.workbench = { version: 1, journal };
2867
+ publishTaskRuntimeRegistry(pi, registry3);
2868
+ return journal;
2869
+ }
2870
+ var TASK_RUNTIME_REGISTRY = "__drone_task_runtime_v1";
2871
+ var TASK_RUNTIME_REQUEST = "drone:task-runtime/request/v1";
2872
+ var TASK_RUNTIME_RESPONSE = "drone:task-runtime/v1";
2873
+ var localTaskRuntimeRegistry = /* @__PURE__ */ new WeakMap();
2874
+ function requestSharedTaskRuntime(pi) {
2875
+ const events = pi?.events;
2876
+ if (!events?.on || !events.emit) return null;
2877
+ let shared = null;
2878
+ const unsubscribe = events.on(TASK_RUNTIME_RESPONSE, (payload) => {
2879
+ if (payload?.version === 1 && payload.registry?.journal) shared = payload.registry;
2880
+ });
2881
+ events.emit(TASK_RUNTIME_REQUEST, { version: 1 });
2882
+ unsubscribe?.();
2883
+ return shared;
2884
+ }
2885
+ function publishTaskRuntimeRegistry(pi, registry3) {
2886
+ const events = pi?.events;
2887
+ if (!events?.on || !events.emit) return;
2888
+ events.on(TASK_RUNTIME_REQUEST, (payload) => {
2889
+ if (payload?.version === 1) events.emit(TASK_RUNTIME_RESPONSE, { version: 1, registry: registry3 });
2890
+ });
2891
+ }
2892
+ function taskRuntimeRegistry(pi) {
2893
+ if (!pi || typeof pi !== "object" && typeof pi !== "function") return null;
2894
+ const owner = pi.events && (typeof pi.events === "object" || typeof pi.events === "function") ? pi.events : pi;
2895
+ const attached = owner[TASK_RUNTIME_REGISTRY];
2896
+ if (attached && attached.version === 1) return attached;
2897
+ const local = localTaskRuntimeRegistry.get(owner);
2898
+ if (local) return local;
2899
+ const registry3 = { version: 1, journal: null };
2900
+ if (Object.isExtensible(owner)) {
2901
+ Object.defineProperty(owner, TASK_RUNTIME_REGISTRY, {
2902
+ value: registry3,
2903
+ enumerable: false,
2904
+ configurable: false,
2905
+ writable: false
2906
+ });
2907
+ } else {
2908
+ localTaskRuntimeRegistry.set(owner, registry3);
2909
+ }
2910
+ return registry3;
2911
+ }
2912
+ function createLegacyTaskJournal(pi) {
2749
2913
  const journal = createTaskJournal({ persist: (snapshot2) => pi.appendEntry?.(TASK_ENTRY, snapshot2) });
2750
2914
  const attach = (ctx, force = false) => {
2751
2915
  const id = ctx.sessionManager?.getSessionId?.() || ctx.sessionId || "isolated";
@@ -12656,6 +12820,10 @@ var KnowledgeContract = defineDomain("knowledge", {
12656
12820
  args: OneObject(),
12657
12821
  result: ResultObject()
12658
12822
  },
12823
+ decideDailyRadarPaper: {
12824
+ args: OneObject(),
12825
+ result: ResultObject()
12826
+ },
12659
12827
  getTopics: {
12660
12828
  args: OneObject(),
12661
12829
  result: ResultObject()
@@ -12956,6 +13124,20 @@ var PackageLifecycleReceiptSchema = typebox_exports.Object(
12956
13124
  },
12957
13125
  { additionalProperties: false }
12958
13126
  );
13127
+ var RegistryPluginMetadataSchema = typebox_exports.Object(
13128
+ {
13129
+ name: typebox_exports.String({ minLength: 1 }),
13130
+ version: typebox_exports.Optional(typebox_exports.String({ minLength: 1 })),
13131
+ description: typebox_exports.Optional(typebox_exports.String()),
13132
+ capabilities: typebox_exports.Array(typebox_exports.String()),
13133
+ tools: typebox_exports.Array(typebox_exports.String()),
13134
+ permissions: typebox_exports.Optional(typebox_exports.Unknown()),
13135
+ hosts: typebox_exports.Array(typebox_exports.String()),
13136
+ packageKind: typebox_exports.Union([typebox_exports.Literal("pi"), typebox_exports.Literal("desktop-ui")]),
13137
+ manifestDeclared: typebox_exports.Boolean()
13138
+ },
13139
+ { additionalProperties: false }
13140
+ );
12959
13141
  var PackagesContract = defineDomain("packages", {
12960
13142
  methods: {
12961
13143
  searchCatalog: {
@@ -12969,6 +13151,14 @@ var PackagesContract = defineDomain("packages", {
12969
13151
  args: typebox_exports.Tuple([typebox_exports.Array(typebox_exports.String({ minLength: 1 }), { maxItems: 50 })]),
12970
13152
  result: typebox_exports.Record(typebox_exports.String(), typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()]))
12971
13153
  },
13154
+ /** Manifest declarations fetched from the npm registry before installation. */
13155
+ pluginPackageMetadata: {
13156
+ args: typebox_exports.Tuple([typebox_exports.Array(typebox_exports.String({ minLength: 1 }), { maxItems: 50 })]),
13157
+ result: typebox_exports.Record(
13158
+ typebox_exports.String(),
13159
+ typebox_exports.Union([typebox_exports.Null(), typebox_exports.Unsafe(RegistryPluginMetadataSchema)])
13160
+ )
13161
+ },
12972
13162
  installPackage: {
12973
13163
  args: typebox_exports.Tuple([typebox_exports.String({ minLength: 1 })]),
12974
13164
  result: typebox_exports.Unsafe(PackageLifecycleReceiptSchema)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gyoungwe/pi-core",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Portable task, authorization, status, delivery and memory tools for native Pi",
5
5
  "keywords": [
6
6
  "pi-package"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gyoungwe/research-suite",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Bundled Drone native Pi research suite",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -45,7 +45,7 @@
45
45
  ]
46
46
  },
47
47
  "dependencies": {
48
- "@gyoungwe/pi-core": "0.1.6",
48
+ "@gyoungwe/pi-core": "0.1.7",
49
49
  "@gyoungwe/pi-knowledge": "0.2.0",
50
50
  "@gyoungwe/pi-research": "0.1.1"
51
51
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "id": "drone-research-suite",
4
- "version": "0.1.6",
4
+ "version": "0.1.7",
5
5
  "pi": {
6
6
  "apiVersion": 1,
7
7
  "minHostVersion": "1.1.0",