@floless/app 0.126.5 → 0.127.0

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.
@@ -52699,6 +52699,12 @@ var AwareUnsupportedError = class extends AwareError {
52699
52699
  this.name = "AwareUnsupportedError";
52700
52700
  }
52701
52701
  };
52702
+ var AwareManagedSidecarContractError = class extends AwareError {
52703
+ constructor(message, detail) {
52704
+ super(message, detail);
52705
+ this.name = "AwareManagedSidecarContractError";
52706
+ }
52707
+ };
52702
52708
  function resolveInvoker() {
52703
52709
  const envDir = process.env.AWARE_CLI_DIR;
52704
52710
  if (envDir && (0, import_node_fs9.existsSync)((0, import_node_path7.join)(envDir, "scripts/bin/aware.js"))) {
@@ -53370,6 +53376,53 @@ function agentUpdateArgv(id) {
53370
53376
  function sidecarInstallArgv(host) {
53371
53377
  return ["sidecar", "install", assertId(host)];
53372
53378
  }
53379
+ function sidecarListArgv() {
53380
+ return ["sidecar", "list"];
53381
+ }
53382
+ function sidecarRepairInstalledArgv() {
53383
+ return ["sidecar", "repair", "--installed"];
53384
+ }
53385
+ var MANAGED_SIDECAR_STATUSES = /* @__PURE__ */ new Set(["current", "stale", "legacy", "missing"]);
53386
+ function parseManagedSidecarInventory(value) {
53387
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
53388
+ throw new AwareManagedSidecarContractError("aware sidecar list returned an invalid managed-sidecar inventory");
53389
+ }
53390
+ const record3 = value;
53391
+ const runtimeVersion = record3["runtime-version"];
53392
+ if (record3["schema-version"] !== 1 || typeof runtimeVersion !== "string" || !Array.isArray(record3.sidecars)) {
53393
+ throw new AwareManagedSidecarContractError("aware CLI does not expose managed-sidecar inventory schema 1 \u2014 update AWARE");
53394
+ }
53395
+ const ids = /* @__PURE__ */ new Set();
53396
+ const sidecars = record3.sidecars.map((row) => {
53397
+ if (!row || typeof row !== "object" || Array.isArray(row)) {
53398
+ throw new AwareManagedSidecarContractError("aware sidecar list returned an invalid sidecar row");
53399
+ }
53400
+ const sidecar = row;
53401
+ const id = sidecar.id;
53402
+ const binary = sidecar.binary;
53403
+ const description = sidecar.description;
53404
+ const status = sidecar.status;
53405
+ const installedVersion = sidecar["installed-version"];
53406
+ const repairEligible = sidecar["repair-eligible"];
53407
+ if (typeof id !== "string" || !id || ids.has(id) || typeof binary !== "string" || !binary || typeof description !== "string" || typeof status !== "string" || !MANAGED_SIDECAR_STATUSES.has(status) || installedVersion !== null && typeof installedVersion !== "string" || typeof repairEligible !== "boolean") {
53408
+ throw new AwareManagedSidecarContractError("aware sidecar list returned an unsupported sidecar row");
53409
+ }
53410
+ ids.add(id);
53411
+ return Object.freeze({
53412
+ id,
53413
+ binary,
53414
+ description,
53415
+ status,
53416
+ installedVersion,
53417
+ repairEligible
53418
+ });
53419
+ });
53420
+ return Object.freeze({
53421
+ schemaVersion: 1,
53422
+ runtimeVersion,
53423
+ sidecars: Object.freeze(sidecars)
53424
+ });
53425
+ }
53373
53426
  function parseAgentInstallOutput(stdout) {
53374
53427
  const m = stdout.match(/✓\s+(?:installed|updated)\s+(\S+)/);
53375
53428
  return { installed: m?.[1] ?? null };
@@ -53759,9 +53812,40 @@ var awareImpl = {
53759
53812
  return { output: stdout.trim() };
53760
53813
  }, opts.signal), opts.signal);
53761
53814
  },
53815
+ /** AWARE's authoritative inventory of managed runtime sidecars. */
53816
+ async managedSidecarInventory() {
53817
+ try {
53818
+ const { data } = await runJson(sidecarListArgv(), 3e4);
53819
+ return parseManagedSidecarInventory(data);
53820
+ } catch (error) {
53821
+ if (error instanceof AwareError && /sidecar list did not return JSON/.test(error.message)) {
53822
+ throw new AwareUnsupportedError("installed AWARE does not support the managed-sidecar inventory contract", error.detail);
53823
+ }
53824
+ throw error;
53825
+ }
53826
+ },
53827
+ /**
53828
+ * Repair every stale installed sidecar in AWARE's own snapshot, then obtain a
53829
+ * fresh inventory. FloLess neither supplies nor parses a sidecar ID list.
53830
+ */
53831
+ async repairInstalledManagedSidecars(opts = {}) {
53832
+ return withAwareShared(() => withSidecarWrite(async () => {
53833
+ const { code, stdout, stderr } = await runRawWithEnv(
53834
+ sidecarRepairInstalledArgv(),
53835
+ void 0,
53836
+ opts.timeoutMs ?? 6e5,
53837
+ opts.onSpawn,
53838
+ opts.signal
53839
+ );
53840
+ if (code !== 0) throw new AwareError(`aware sidecar repair --installed failed (exit ${code})`, { stdout, stderr });
53841
+ return this.managedSidecarInventory();
53842
+ }, opts.signal), opts.signal);
53843
+ },
53762
53844
  /**
53763
- * Ensure the connection-reader bridge (the web-ifc Node SEA) is present, idempotently: if it's
53764
- * already in ~/.aware/bridges/ this is a cheap no-op; otherwise fetch it via `sidecar install`.
53845
+ * Ensure the connection-reader bridge (the web-ifc Node SEA) is present.
53846
+ * Catalogue-wide stale-sidecar repair belongs to the caller's exclusive
53847
+ * lifecycle boundary (`aware-managed-sidecars`); this method retains only
53848
+ * the legacy presence/install behavior for the reader it directly needs.
53765
53849
  * `aware app run` on a connection-reader node needs this bridge (the tessellator is web-ifc, not
53766
53850
  * Rust) — the reader agent's manifest alone isn't enough.
53767
53851
  */
@@ -54650,7 +54734,7 @@ function appVersion() {
54650
54734
  return resolveVersion({
54651
54735
  isSea: isSea2(),
54652
54736
  sqVersionXml: readSqVersionXml(),
54653
- define: true ? "0.126.5" : void 0,
54737
+ define: true ? "0.127.0" : void 0,
54654
54738
  pkgVersion: readPkgVersion()
54655
54739
  });
54656
54740
  }
@@ -54666,7 +54750,7 @@ function resolveChannel(s) {
54666
54750
  function appChannel() {
54667
54751
  return resolveChannel({
54668
54752
  isSea: isSea2(),
54669
- define: true ? "0.126.5" : void 0,
54753
+ define: true ? "0.127.0" : void 0,
54670
54754
  // argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
54671
54755
  // carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
54672
54756
  modulePath: process.argv[1]
@@ -59851,7 +59935,8 @@ var TYPE_SET = {
59851
59935
  "new-workflow": true,
59852
59936
  "revision-read": true,
59853
59937
  "knowledge-organize": true,
59854
- "knowledge-adjust": true
59938
+ "knowledge-adjust": true,
59939
+ "knowledge-consult": true
59855
59940
  };
59856
59941
  var REQUEST_TYPES = Object.keys(TYPE_SET);
59857
59942
  function isRequestType(t) {
@@ -60040,6 +60125,7 @@ var RUN_POLICY = {
60040
60125
  why: "organizing holds a lock a killed run can\u2019t release \u2014 do this one in your terminal"
60041
60126
  },
60042
60127
  "knowledge-adjust": { runnable: false, why: "organizing holds a lock a killed run can\u2019t release \u2014 do this one in your terminal" },
60128
+ "knowledge-consult": { runnable: false, why: "it changes the workflow structure \u2014 do this one in your terminal" },
60043
60129
  guide: { runnable: false, why: "this one is a conversation \u2014 headless would talk to nobody" },
60044
60130
  "new-workflow": { runnable: false, why: "this one is a conversation \u2014 headless would talk to nobody" }
60045
60131
  };
@@ -60207,6 +60293,41 @@ New drawing${req.snapshots.length > 1 ? "s" : ""} (read for the re-extraction):
60207
60293
  if (req.type === "new-workflow") {
60208
60294
  return `Help me build a brand-new floless workflow from scratch, step by step, with your floless-app-new-workflow skill. Ask me what I want it to do, then before writing any node confirm the agents it needs are installed (offer to install a missing one from the catalogue, or to report a not-yet-existing agent as an idea). Author the .flo node by node, verifying each step is correct (plain-English descriptions, validate, compile, a real run), and finish by installing \u2192 Compile \u2192 \u25B6 Run so I can see it work and approve.`;
60209
60295
  }
60296
+ if (req.type === "knowledge-consult") {
60297
+ return `In floless app "${req.appId}", add the proven deterministic knowledge-consult pair below. Preserve the existing workflow and its inputs, requires, nodes, and connections; add only missing inputs/requires, and choose non-colliding ids if "kb" or "gate" already exists. Do not add a model or agent that interprets knowledge, a vector store, a knowledge-drift Run gate, or any other run-time decision. The knowledge read is retrieval only; its deterministic predicate may gate downstream work. Give the new nodes their plain-English descriptions (the floless-workspace command description for kb and the inline description for gate), then compile the FloLess .flo workflow so the user can choose a project and subject before running.
60298
+
60299
+ \`\`\`yaml
60300
+ inputs:
60301
+ project_id:
60302
+ type: string
60303
+ default: ""
60304
+ widget: workspace-knowledge-project
60305
+ description: Workspace project whose published knowledge this workflow consults.
60306
+ subject:
60307
+ type: string
60308
+ default: ""
60309
+ description: Subject used to rank the project's knowledge pages.
60310
+ requires:
60311
+ - floless-workspace@0.2.x
60312
+ nodes:
60313
+ - id: kb
60314
+ agent: floless-workspace
60315
+ command: read-knowledge
60316
+ mode: read
60317
+ config:
60318
+ project-id: "{{ inputs.project_id }}"
60319
+ q: "{{ inputs.subject }}"
60320
+ - id: gate
60321
+ inline:
60322
+ kind: predicate
60323
+ description: Continue only when the knowledge-base read returned HTTP 200; organize the project's Knowledge step and try again if it cannot be read.
60324
+ code: "e.status == 200"
60325
+ connections:
60326
+ - { from: kb, to: gate }
60327
+ \`\`\`
60328
+
60329
+ This is a required structural edit, not optional advice: find the workflow's existing terminal report node, replace its prior incoming terminal connection with \`gate \u2192 <terminal-report-id>\`, and keep every upstream node that report still needs connected through the workflow. Do not leave \`kb \u2192 gate\` as a disconnected branch. Add report args for the consulted generation and top page, using exactly \`kb.body.generation.generationId\` and \`kb.body.pages[0].slug\`; guard each deep reference with \`{% if kb.body.generation %}\` and \`{% if kb.body.pages %}\` before resolving it, because minijinja raises before \`default()\` can run. Render those args in the terminal report as the generation and top-page citation. If this workflow has no terminal report that can visibly cite the read, stop and explain that instead of adding a disconnected pair. If the read returns no published KB or no match, keep the report honest and direct the user to Organize; do not claim the run was informed.`;
60330
+ }
60210
60331
  if (req.type === "revision-read") {
60211
60332
  const isInitialRead = !req.baseVersion || req.baseVersion <= 0;
60212
60333
  const snaps = req.snapshots && req.snapshots.length ? `
@@ -60261,7 +60382,8 @@ var REQUEST_SKILL = {
60261
60382
  "new-workflow": "floless-app-new-workflow",
60262
60383
  // Project Knowledge Base: one self-contained skill drives both the organize lifecycle and adjusts.
60263
60384
  "knowledge-organize": "floless-app-knowledge",
60264
- "knowledge-adjust": "floless-app-knowledge"
60385
+ "knowledge-adjust": "floless-app-knowledge",
60386
+ "knowledge-consult": "floless-app-workflows"
60265
60387
  };
60266
60388
  function markerFor(req, base, body = instructionFor(req)) {
60267
60389
  if (!body) return "";
@@ -60302,6 +60424,35 @@ function enrichedView(r, enrich, base = selfOrigin()) {
60302
60424
  var import_node_fs27 = require("node:fs");
60303
60425
  var import_node_path26 = require("node:path");
60304
60426
 
60427
+ // aware-managed-sidecars.ts
60428
+ var liveDeps = {
60429
+ inventory: () => aware.managedSidecarInventory(),
60430
+ repair: () => aware.repairInstalledManagedSidecars(),
60431
+ withExclusive: (fn) => withAwareExclusive(fn)
60432
+ };
60433
+ var needsRepair = (inventory) => inventory.sidecars.filter((sidecar) => sidecar.repairEligible).length;
60434
+ async function ensureManagedSidecarsForUserAction(deps = liveDeps) {
60435
+ let initial;
60436
+ try {
60437
+ initial = await deps.inventory();
60438
+ } catch (error) {
60439
+ if (error instanceof AwareUnsupportedError) return { supported: false, repaired: 0 };
60440
+ throw error;
60441
+ }
60442
+ if (needsRepair(initial) === 0) return { supported: true, repaired: 0 };
60443
+ return deps.withExclusive(async () => {
60444
+ const before = await deps.inventory();
60445
+ const count = needsRepair(before);
60446
+ if (count === 0) return { supported: true, repaired: 0 };
60447
+ const after = await deps.repair();
60448
+ const remaining2 = needsRepair(after);
60449
+ if (remaining2 > 0) {
60450
+ throw new AwareError(`AWARE left ${remaining2} managed runtime tool(s) needing repair.`);
60451
+ }
60452
+ return { supported: true, repaired: count };
60453
+ });
60454
+ }
60455
+
60305
60456
  // ifc-frame.ts
60306
60457
  var FILE_Z_UP = "z-up";
60307
60458
  var FILE_Y_UP = "y-up";
@@ -60324,6 +60475,7 @@ var ConnectionImportError = class extends Error {
60324
60475
  };
60325
60476
  async function ensureConnectionReader() {
60326
60477
  try {
60478
+ await ensureManagedSidecarsForUserAction();
60327
60479
  await aware.ensureAgentInstalled(AGENT);
60328
60480
  await aware.ensureConnectionReaderBridge();
60329
60481
  } catch (e) {
@@ -70137,6 +70289,7 @@ function writeReaderApp2(companionId, command, ifcPath, filter) {
70137
70289
  }
70138
70290
  async function ensureReferenceReader() {
70139
70291
  try {
70292
+ await ensureManagedSidecarsForUserAction();
70140
70293
  await aware.ensureAgentInstalled(AGENT2);
70141
70294
  await aware.ensureConnectionReaderBridge();
70142
70295
  } catch (e) {
@@ -86588,7 +86741,11 @@ async function startServer() {
86588
86741
  signal: context.signal,
86589
86742
  onChild: context.childStarted
86590
86743
  }),
86591
- refreshRuntime: () => refreshInvoker(),
86744
+ refreshRuntime: () => {
86745
+ refreshInvoker();
86746
+ disarmAutoBridgeRepair();
86747
+ scheduleAutoBridgeRepair();
86748
+ },
86592
86749
  invalidateVersion: invalidateAwareVersion,
86593
86750
  probeRuntime: () => aware.npmVersion(),
86594
86751
  smokeRuntime: async () => aware.smoke(),
@@ -86684,11 +86841,43 @@ async function startServer() {
86684
86841
  function disarmAutoBridgeRepair() {
86685
86842
  detachAutoRepairIdleWatch?.();
86686
86843
  detachAutoRepairIdleWatch = null;
86844
+ autoRepairScheduled = false;
86845
+ }
86846
+ async function staleManagedSidecarsForInstalledRuntime() {
86847
+ try {
86848
+ const inventory = await aware.managedSidecarInventory();
86849
+ return inventory.sidecars.filter((sidecar) => sidecar.repairEligible).length;
86850
+ } catch (error) {
86851
+ if (error instanceof AwareUnsupportedError) return null;
86852
+ throw error;
86853
+ }
86687
86854
  }
86688
86855
  async function attemptAutoBridgeRepair() {
86689
86856
  if (autoRepairInFlight || SKIP_AUTO_BRIDGE_REPAIR) return;
86690
86857
  autoRepairInFlight = true;
86691
86858
  try {
86859
+ const managedSidecarsNeedingRepair = await staleManagedSidecarsForInstalledRuntime();
86860
+ if (managedSidecarsNeedingRepair === 0) {
86861
+ disarmAutoBridgeRepair();
86862
+ return;
86863
+ }
86864
+ if (managedSidecarsNeedingRepair !== null) {
86865
+ const outcome2 = await tryWithAwareExclusiveIfIdle("auto", async () => {
86866
+ const before = await aware.managedSidecarInventory();
86867
+ if (!before.sidecars.some((sidecar) => sidecar.repairEligible)) return;
86868
+ const after = await aware.repairInstalledManagedSidecars();
86869
+ const remaining2 = after.sidecars.filter((sidecar) => sidecar.repairEligible);
86870
+ if (remaining2.length) {
86871
+ throw new Error(`AWARE left ${remaining2.length} managed runtime tool(s) needing repair.`);
86872
+ }
86873
+ app.log.info(
86874
+ { repaired: before.sidecars.filter((sidecar) => sidecar.repairEligible).length },
86875
+ "repaired stale AWARE managed runtime tools"
86876
+ );
86877
+ });
86878
+ if (outcome2.ran) disarmAutoBridgeRepair();
86879
+ return;
86880
+ }
86692
86881
  if (!await staleBridgesForInstalledRuntime()) {
86693
86882
  disarmAutoBridgeRepair();
86694
86883
  return;
@@ -89957,6 +90146,13 @@ async function startServer() {
89957
90146
  broadcast({ type: "request-added", request });
89958
90147
  return { ok: true, request: requestView2(request) };
89959
90148
  });
90149
+ app.post("/api/knowledge-consult", async (req, reply) => {
90150
+ const { appId } = req.body ?? {};
90151
+ if (!appId) return reply.status(400).send({ ok: false, error: "appId required" });
90152
+ const request = addRequest({ type: "knowledge-consult", appId });
90153
+ broadcast({ type: "request-added", request });
90154
+ return { ok: true, request: requestView2(request) };
90155
+ });
89960
90156
  app.post("/api/guide-new", async (_req, _reply) => {
89961
90157
  const request = addRequest({ type: "new-workflow" });
89962
90158
  broadcast({ type: "request-added", request });
@@ -2,14 +2,14 @@
2
2
  name: floless-app-queue
3
3
  description: This skill should be used when the user has MULTIPLE floless.app requests queued from the Dashboard and wants to see them and choose which to process, rather than the AI just picking up the oldest one. Use it when the user says things like "what's in my floless queue", "list my queued floless requests", "show me the pending requests and let me pick", "I queued a few tweaks — which should I apply?", "let me choose what to process", or "pick from the floless queue". It lists the pending requests from GET /api/requests in plain language (type, which app/node/project, the instruction), asks the user which one(s) to apply, then hands each chosen request to the owning skill (floless-app-workflows / -tweak-contract / -ui / -rebake / -onboarding / -new-workflow / -steel-takeoff / -vectorize / -knowledge) which applies it and clears it. It is the interactive picker that sits in front of floless-app-bridge (which is the actual pull-apply-clear engine).
4
4
  metadata:
5
- version: 0.2.2
5
+ version: 0.2.3
6
6
  ---
7
7
 
8
8
  # floless.app queue picker
9
9
 
10
10
  floless.app is the **thin web UI**; the **terminal AI (you) is the brain**. The UI cannot edit
11
11
  `.flo` files — it **queues requests** (Tweak / use-template / customize-UI / rebake / edit-contract /
12
- walk-me-through / new-workflow / read-this-drawing / organize-or-adjust-the-knowledge-base) to a
12
+ walk-me-through / new-workflow / read-this-drawing / organize-or-adjust-the-knowledge-base / add-a-deterministic-knowledge-consult) to a
13
13
  local API. The **`floless-app-bridge`** skill pulls those and applies them, but it processes
14
14
  the queue **oldest-first with no choice step**. This skill adds the missing affordance: **list the
15
15
  whole queue in plain English and let the user pick which one(s) to process** — then route each pick
@@ -57,6 +57,7 @@ map to:
57
57
  | `revision-read` | "Read the attached drawing(s) into project **`<project>`** as a new version (+N file(s))" — the **initial** read when `baseVersion` is absent or ≤ 0, otherwise a **re-read** of a revised set | `floless-app-steel-takeoff` — but `floless-app-vectorize` when the app's lineage root (`appTemplateId`, falling back to `appId`) is `vectorize` |
58
58
  | `knowledge-organize` | "Organize the Project Knowledge Base for project **`<project>`**" | `floless-app-knowledge` |
59
59
  | `knowledge-adjust` | "Reshape the Project Knowledge Base for project **`<project>`** — *<instruction>*" | `floless-app-knowledge` |
60
+ | `knowledge-consult` | "Add a deterministic Workspace knowledge read (`kb`) and HTTP-200 gate (`gate`) to **`<appId>`**, then compile" | `floless-app-workflows` |
60
61
 
61
62
  The type union itself is `FlolessRequest` in `server/floless-store.ts` — a type in the union with no row
62
63
  above means this table is stale, and the union is right. The routing is `REQUEST_SKILL` in
@@ -2,7 +2,7 @@
2
2
  name: floless-app-workflows
3
3
  description: This skill should be used when building, modifying, or reasoning about FloLess .flo workflows for floless.app — especially reusable apps that take inputs (e.g. a phase number) and run across different Tekla models, exec nodes that run Roslyn C# against the live model, the in-app HTML Viewer, the Code tab, or "Debug in VS". Covers the exec contract, the install→validate→compile→run loop, app inputs templating, reading an approved Workspace project's data from a running workflow via the floless-workspace REST seam plus its workspace-project input picker, and the server seams (aware-adapter, app-reader, index).
4
4
  metadata:
5
- version: 0.5.0
5
+ version: 0.5.2
6
6
  ---
7
7
 
8
8
  # Building reusable .flo workflows in floless.app
@@ -316,6 +316,36 @@ Let the user **pick** the project (never type an opaque id): flag the input
316
316
  (by name, searchable) and stores the opaque id. Client-only hint, never sent to `aware`
317
317
  (like `widget: file`); optional `workspaceApp:` pre-filters to one app. See `references/workspace-data.md`.
318
318
 
319
+ ## Consult and cite the project's knowledge at run time — retrieval only
320
+
321
+ Use `floless-workspace/read-knowledge` only when a run must retrieve a project's compiled knowledge
322
+ summaries. It is not a model or an interpretation step: AWARE receives a normal REST read, and the
323
+ approved `.lock` still determines every run decision. Add `floless-workspace@0.2.x`, then use the
324
+ proven `kb → gate` pair from `demos/floless-workspace-knowledge`:
325
+
326
+ The `kb` and `gate` pair must feed the existing terminal report. A pair that is not on the terminal
327
+ report path is incomplete: it reads knowledge without making the report's provenance visible.
328
+
329
+ Let the user pick the target by name with **`widget: workspace-knowledge-project`**. The themed
330
+ picker calls `GET /api/workspace-projects` and offers only rows where `hasKnowledge` is true; it does
331
+ not use `workspace-project` or `/approved`, because model approval is unrelated to published knowledge.
332
+ Its empty state must send the user to **Organize** the project's Knowledge step, never to approve a
333
+ model.
334
+
335
+ - **Cite:** pass `kb.body.generation.generationId` and the top page slug to a downstream report so it
336
+ can say which generation/page it consulted. Both `generation` and `pages[0]` are optional on a 200:
337
+ use `{% if kb.body.generation %}…{% endif %}` and `{% if kb.body.pages %}…{% endif %}` to short-circuit
338
+ each deep reference. `default()` cannot protect an undefined path because minijinja raises while
339
+ resolving the path, before applying the filter.
340
+ - **Gate:** put `inline: { kind: predicate, code: "e.status == 200" }` immediately after the read.
341
+ Its plain-English `description:` must say it stops cleanly when the read fails and directs the user
342
+ to press **Organize** on the project's Knowledge step. A 200 with no published knowledge or no page
343
+ matching the subject is legitimate retrieval, not an excuse to invent a citation; make the report
344
+ say so honestly.
345
+
346
+ Never add an agent/LLM node, vector store, or KB-drift Run gate to this path. Interpretation belongs
347
+ at compose time; runtime knowledge may only be retrieved, cited, or deterministically gated.
348
+
319
349
  ## Author against the project's knowledge, not your priors — COMPOSE TIME
320
350
 
321
351
  The section above is the workflow reading project data **at run time**. This is a different thing:
package/dist/web/app.css CHANGED
@@ -1078,6 +1078,13 @@
1078
1078
  transition: all 0.15s;
1079
1079
  user-select: none;
1080
1080
  }
1081
+ button.fav-chip {
1082
+ appearance: none;
1083
+ font: inherit;
1084
+ color: inherit;
1085
+ cursor: pointer;
1086
+ }
1087
+ button.fav-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
1081
1088
  .fav-chip:hover {
1082
1089
  border-color: var(--accent);
1083
1090
  transform: translateY(-1px);
package/dist/web/aware.js CHANGED
@@ -1050,6 +1050,9 @@
1050
1050
  // publication clears, rather than keeping the previous answer forever.
1051
1051
  await commitPublicationAvailability(id, read, contractState);
1052
1052
  currentId = id;
1053
+ // The Templates strip also carries app-scoped quick actions. Templates may have
1054
+ // loaded before this app did, so repaint it once the ownership boundary is known.
1055
+ renderFavBar();
1053
1056
  try { localStorage.setItem(LS_LAST_APP, id); } catch { /* private mode / quota */ }
1054
1057
  transform(app);
1055
1058
  liveTrace.length = 0;
@@ -2404,6 +2407,17 @@
2404
2407
  } catch { return []; }
2405
2408
  }
2406
2409
 
2410
+ // Knowledge reads are scoped by a published knowledge base, never by a model approval. Keep this
2411
+ // separate from `workspace-project`: approval answers whether a model is runnable, while this
2412
+ // picker answers whether the project has knowledge the read-knowledge node can consult.
2413
+ async function fetchKnowledgeProjects() {
2414
+ try {
2415
+ const r = await fetch('/api/workspace-projects');
2416
+ const j = await r.json().catch(() => null);
2417
+ return j && j.ok && Array.isArray(j.projects) ? j.projects.filter((p) => p && p.hasKnowledge === true) : [];
2418
+ } catch { return []; }
2419
+ }
2420
+
2407
2421
  // Double-click the input node → styled dialog to set the declared inputs. Writes
2408
2422
  // to appInputValues; the header "▶ Run workflow" uses them. No native window.prompt.
2409
2423
  async function openInputsDialog() {
@@ -2412,6 +2426,7 @@
2412
2426
  const cur = currentInputs();
2413
2427
  const isVisual = (inp) => inp.widget === 'file' || inp.type === 'image' || inp.type === 'file';
2414
2428
  const isProject = (inp) => inp.widget === 'workspace-project';
2429
+ const isKnowledgeProject = (inp) => inp.widget === 'workspace-knowledge-project';
2415
2430
  const visualNames = new Set(app.inputs.filter(isVisual).map((i) => i.name));
2416
2431
  // A project-picker input needs the live list of approved projects. Fetch ONE list per DISTINCT
2417
2432
  // `workspaceApp` filter and let the SERVER decide what matches, rather than fetching everything
@@ -2428,6 +2443,7 @@
2428
2443
  .map((i) => (typeof i.workspaceApp === 'string' && i.workspaceApp ? i.workspaceApp : '')))];
2429
2444
  const approvedByFilter = new Map();
2430
2445
  for (const f of projectFilters) approvedByFilter.set(f, await fetchApprovedProjects(f || undefined));
2446
+ const knowledgeProjects = app.inputs.some(isKnowledgeProject) ? await fetchKnowledgeProjects() : [];
2431
2447
  const fields = app.inputs.map((inp) => {
2432
2448
  if (isVisual(inp)) return {
2433
2449
  name: inp.name,
@@ -2459,6 +2475,26 @@
2459
2475
  emptyNote: 'No approved projects yet — open <strong>Workspaces</strong>, create a project, and Approve it to use it here.',
2460
2476
  };
2461
2477
  }
2478
+ if (isKnowledgeProject(inp)) {
2479
+ const options = knowledgeProjects
2480
+ .slice().sort((a, b) => String(a.name).localeCompare(String(b.name)))
2481
+ .map((p) => ({
2482
+ value: p.id,
2483
+ meta: `${appLabel(p.templateId || p.app)} · Knowledge published`,
2484
+ label: p.name,
2485
+ search: `${p.name} ${p.id} ${p.app} ${appLabel(p.templateId || p.app)}`,
2486
+ }));
2487
+ return {
2488
+ name: inp.name,
2489
+ label: inp.name + (inp.description ? ` — ${inp.description}` : ''),
2490
+ type: 'select',
2491
+ options,
2492
+ value: cur[inp.name] != null ? cur[inp.name] : '',
2493
+ placeholder: 'Select a project with knowledge…',
2494
+ disabledLabel: 'No project knowledge yet',
2495
+ emptyNote: 'No Workspace project has published knowledge yet — open <strong>Workspaces</strong>, choose a project, and Organize its Knowledge step before running this workflow.',
2496
+ };
2497
+ }
2462
2498
  return {
2463
2499
  name: inp.name,
2464
2500
  label: inp.name + (inp.description ? ` — ${inp.description}` : ''),
@@ -6894,20 +6930,40 @@
6894
6930
  catch (e) { reportErr(e); }
6895
6931
  }
6896
6932
 
6933
+ async function requestKnowledgeConsult() {
6934
+ const app = currentId && apps.get(currentId);
6935
+ // A maintained workflow is form-only until the user explicitly forks it. Hide the affordance in
6936
+ // renderFavBar in that state, and retain this guard so a stale DOM click cannot queue a logic edit.
6937
+ if (!app || (app.publisher === 'floless' && !app.forked)) return;
6938
+ try {
6939
+ const { request } = await api('/api/knowledge-consult', { method: 'POST', body: JSON.stringify({ appId: app.id }) });
6940
+ const copied = await copyToClipboard(markedInstruction(request));
6941
+ appendNarration(`Queued a deterministic <code>kb → gate</code> knowledge read for <code>${escapeHtml(app.id)}</code> — your terminal AI will add it. Choose the project and subject, then compile.${copied ? ' The instruction is on your clipboard.' : ''}`);
6942
+ showToast(copied ? 'Knowledge read + gate queued · copied to clipboard' : 'Knowledge read + gate queued', 'ok');
6943
+ loadRequests();
6944
+ } catch (e) { reportErr(e); }
6945
+ }
6946
+
6897
6947
  // Template chips: click = "use in this app" (reverse channel); × = delete.
6898
6948
  renderFavBar = function renderFavBarTpl() {
6949
+ const app = currentId && apps.get(currentId);
6950
+ const canConsultKnowledge = !!app && !(app.publisher === 'floless' && !app.forked);
6899
6951
  const tpls = state.favorites;
6900
6952
  $favCount.textContent = tpls.length;
6901
- if (!tpls.length) { $favChipRow.innerHTML = ''; $favBarEmpty.style.display = 'block'; return; }
6902
- $favBarEmpty.style.display = 'none';
6903
- $favChipRow.innerHTML = tpls.map((t) => `
6953
+ $favBarEmpty.style.display = tpls.length ? 'none' : 'block';
6954
+ $favChipRow.innerHTML = (canConsultKnowledge
6955
+ ? `<button type="button" class="fav-chip knowledge-consult" data-knowledge-consult data-tip="Add a knowledge read and deterministic gate to this workflow. Choose the project and subject before compiling."><span class="cat">ADD</span><span class="name">Consult knowledge</span></button>`
6956
+ : '') + tpls.map((t) => `
6904
6957
  <div class="fav-chip" data-tpl="${escapeAttr(t.id)}" data-tip="Click to use · ${escapeAttr(t.category)} · ${escapeAttr((t.node.agent || t.node.kind) + (t.node.command ? '/' + t.node.command : ''))}">
6905
6958
  <span class="cat">${escapeHtml(t.category)}</span>
6906
6959
  <span class="name">${escapeHtml(t.name)}</span>
6907
6960
  <span class="edit" data-tip="Rename / recategorize" aria-label="Edit template">✎</span>
6908
6961
  <span class="del" data-tip="Delete template" aria-label="Delete template">×</span>
6909
6962
  </div>`).join('');
6963
+ const consult = $favChipRow.querySelector('[data-knowledge-consult]');
6964
+ if (consult) consult.onclick = requestKnowledgeConsult;
6910
6965
  $favChipRow.querySelectorAll('.fav-chip').forEach((chip) => {
6966
+ if (chip.dataset.knowledgeConsult !== undefined) return;
6911
6967
  const id = chip.dataset.tpl;
6912
6968
  chip.onclick = (e) => { if (e.target.closest('.del') || e.target.closest('.edit')) return; useTemplate(id); };
6913
6969
  chip.querySelector('.edit').onclick = (e) => { e.stopPropagation(); openEditTemplate(id); };
@@ -7381,7 +7437,7 @@
7381
7437
  }
7382
7438
 
7383
7439
  function requestLabel(r) {
7384
- return r.type === 'use-template' ? 'template' : r.type === 'ui-customize' ? 'dashboard' : r.type === 'rebake' ? 're-bake' : r.type === 'revision-read' ? 'revision' : r.type === 'guide' ? 'guide' : r.type === 'new-workflow' ? 'new workflow' : r.type === 'knowledge-organize' ? 'organize' : r.type === 'knowledge-adjust' ? 'adjust' : r.type === 'tweak-contract' ? 'contract' : 'tweak';
7440
+ return r.type === 'use-template' ? 'template' : r.type === 'ui-customize' ? 'dashboard' : r.type === 'rebake' ? 're-bake' : r.type === 'revision-read' ? 'revision' : r.type === 'guide' ? 'guide' : r.type === 'new-workflow' ? 'new workflow' : r.type === 'knowledge-organize' ? 'organize' : r.type === 'knowledge-adjust' ? 'adjust' : r.type === 'knowledge-consult' ? 'knowledge' : r.type === 'tweak-contract' ? 'contract' : 'tweak';
7385
7441
  }
7386
7442
 
7387
7443
  // Escape `text`, wrapping every case-insensitive occurrence of `q` in <mark>. Splits the RAW
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.126.5",
3
+ "version": "0.127.0",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {