happy-imou-cloud 2.1.32 → 2.1.34

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 (25) hide show
  1. package/dist/{BaseReasoningProcessor-CfibmGoR.mjs → BaseReasoningProcessor-CxLnyixP.mjs} +2 -2
  2. package/dist/{BaseReasoningProcessor-CQQrYyo3.cjs → BaseReasoningProcessor-kN8gq-t4.cjs} +2 -2
  3. package/dist/{ProviderSelectionHandler-C1q60HP6.mjs → ProviderSelectionHandler-DuJGNviz.mjs} +2 -2
  4. package/dist/{ProviderSelectionHandler-D9Bd_S25.cjs → ProviderSelectionHandler-oEEvSQ0O.cjs} +2 -2
  5. package/dist/{api-DIFbsA6t.mjs → api-B3Zl8oHG.mjs} +105 -5
  6. package/dist/{api-DeDVledu.cjs → api-C94O6IB2.cjs} +106 -4
  7. package/dist/{command-Cl7kVs7K.cjs → command-96cX402J.cjs} +2 -2
  8. package/dist/{command-ZJ5yPOv4.mjs → command-CMZlS6zf.mjs} +2 -2
  9. package/dist/{index-CT1dgGsX.cjs → index-D4TuE2VS.cjs} +140 -37
  10. package/dist/{index-CFH8qcTw.mjs → index-sqm5plVs.mjs} +137 -34
  11. package/dist/index.cjs +2 -2
  12. package/dist/index.mjs +2 -2
  13. package/dist/lib.cjs +1 -1
  14. package/dist/lib.d.cts +412 -0
  15. package/dist/lib.d.mts +412 -0
  16. package/dist/lib.mjs +1 -1
  17. package/dist/{registerKillSessionHandler-9O3r5bEa.cjs → registerKillSessionHandler-7bLVg5RG.cjs} +233 -11
  18. package/dist/{registerKillSessionHandler-DxpGgu6u.mjs → registerKillSessionHandler-Dmm6gsoz.mjs} +233 -11
  19. package/dist/{runClaude-BvRjHUgF.mjs → runClaude-BrvxWJ9-.mjs} +4 -4
  20. package/dist/{runClaude-BmW-_Yrl.cjs → runClaude-Dn1JJ8m9.cjs} +4 -4
  21. package/dist/{runCodex-dmjiaB1v.cjs → runCodex-Dc2Rqb8W.cjs} +5 -5
  22. package/dist/{runCodex-B-B9MfOf.mjs → runCodex-DfYO-7YG.mjs} +5 -5
  23. package/dist/{runGemini-B9W7nfow.mjs → runGemini-C1_AOBlU.mjs} +4 -4
  24. package/dist/{runGemini-CyERhKhw.cjs → runGemini-DQyuAba-.cjs} +4 -4
  25. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chalk = require('chalk');
4
- var persistence = require('./api-DeDVledu.cjs');
4
+ var persistence = require('./api-C94O6IB2.cjs');
5
5
  var z = require('zod');
6
6
  var fs$2 = require('fs/promises');
7
7
  var os$1 = require('os');
@@ -72,7 +72,7 @@ async function openBrowser(url) {
72
72
  }
73
73
  }
74
74
 
75
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CT1dgGsX.cjs', document.baseURI).href)));
75
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-D4TuE2VS.cjs', document.baseURI).href)));
76
76
  const QRCode = require$1("qrcode-terminal/vendor/QRCode");
77
77
  const QRErrorCorrectLevel = require$1("qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel");
78
78
  const pendingTempFiles = /* @__PURE__ */ new Set();
@@ -637,7 +637,7 @@ function setupCleanupHandlers() {
637
637
  });
638
638
  }
639
639
 
640
- const __dirname$2 = path$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CT1dgGsX.cjs', document.baseURI).href))));
640
+ const __dirname$2 = path$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-D4TuE2VS.cjs', document.baseURI).href))));
641
641
  function projectPath() {
642
642
  const path = path$1.resolve(__dirname$2, "..");
643
643
  return path;
@@ -5106,6 +5106,20 @@ function normalizeRef(value) {
5106
5106
  const trimmed = value?.trim().toLowerCase();
5107
5107
  return trimmed ? trimmed : null;
5108
5108
  }
5109
+ function normalizeOptionalValue(value) {
5110
+ const trimmed = value?.trim();
5111
+ return trimmed ? trimmed : null;
5112
+ }
5113
+ function readDispatchValidationMode(parsed) {
5114
+ const raw = normalizeRef(readSingleValue(parsed, "validation-mode"));
5115
+ if (!raw || raw === "shadow") {
5116
+ return "shadow";
5117
+ }
5118
+ if (raw === "hard") {
5119
+ return "hard";
5120
+ }
5121
+ throw new Error(`Invalid --validation-mode value: ${raw}`);
5122
+ }
5109
5123
  function resolveMemberAgent(agents, opts) {
5110
5124
  const memberId = normalizeRef(opts.memberId);
5111
5125
  if (memberId) {
@@ -5120,29 +5134,91 @@ function resolveMemberAgent(agents, opts) {
5120
5134
  }
5121
5135
  const memberName = normalizeRef(opts.memberName);
5122
5136
  if (memberName) {
5123
- const exactMatches = agents.filter((agent) => !agent.isRoot && normalizeRef(agent.name) === memberName);
5124
- if (exactMatches.length === 1) {
5125
- return exactMatches[0];
5126
- }
5127
- if (exactMatches.length > 1) {
5128
- throw new Error(`Multiple members matched --member-name ${opts.memberName}; use --member-id instead`);
5129
- }
5130
- throw new Error(`No member found for --member-name ${opts.memberName}`);
5137
+ throw new Error("Dispatch send no longer supports --member-name as formal routing truth; use --member-id or truth-resolvable --position-id/--responsibility-id instead");
5131
5138
  }
5132
5139
  const scope = normalizeRef(opts.scope);
5133
5140
  if (!scope) {
5134
- throw new Error("Dispatch send requires --scope and either --member-id, --member-name, or a unique scope match");
5141
+ throw new Error("Dispatch send requires --scope and formal truth via --member-id or truth-resolvable --position-id/--responsibility-id");
5135
5142
  }
5136
- const candidates = agents.filter(
5137
- (agent) => !agent.isRoot && (normalizeRef(agent.name) === scope || normalizeRef(agent.role) === scope)
5138
- );
5139
- if (candidates.length === 1) {
5140
- return candidates[0];
5143
+ throw new Error(`Dispatch send no longer resolves formal targets from --scope ${opts.scope}; scope is hint-only now`);
5144
+ }
5145
+ function findAgentById(agents, agentId) {
5146
+ const normalizedAgentId = normalizeRef(agentId);
5147
+ if (!normalizedAgentId) {
5148
+ return null;
5141
5149
  }
5142
- if (candidates.length > 1) {
5143
- throw new Error(`Multiple members matched --scope ${opts.scope}; use --member-id instead`);
5150
+ return agents.find((agent) => normalizeRef(agent.id) === normalizedAgentId) ?? null;
5151
+ }
5152
+ function findResponsibilityMemberId(view, responsibilityId) {
5153
+ const normalizedResponsibilityId = normalizeRef(responsibilityId);
5154
+ if (!view?.home.responsibilityBoard || !normalizedResponsibilityId) {
5155
+ return null;
5144
5156
  }
5145
- throw new Error(`No member matched --scope ${opts.scope}`);
5157
+ return view.home.responsibilityBoard.items.find((item) => normalizeRef(item.responsibilityId) === normalizedResponsibilityId)?.memberAgentId ?? null;
5158
+ }
5159
+ function finalizeDispatchValidation(params) {
5160
+ return {
5161
+ requestedMemberAgentId: params.requestedMemberAgentId,
5162
+ positionTruthAgentId: params.positionTruthAgentId,
5163
+ responsibilityTruthMemberAgentId: params.responsibilityTruthMemberAgentId,
5164
+ liveBindingSessionId: params.liveBindingSessionId,
5165
+ runtimeSessionId: params.runtimeSessionId,
5166
+ validationResult: params.rejectionReason ? params.mode === "hard" ? "hard_reject" : "shadow_would_reject" : params.mode === "hard" ? "hard_pass" : "shadow_pass",
5167
+ rejectionReason: params.rejectionReason
5168
+ };
5169
+ }
5170
+ async function resolveFormalDispatchTarget(params) {
5171
+ const requestedMemberId = normalizeOptionalValue(readSingleValue(params.parsed, "member-id"));
5172
+ const requestedMember = requestedMemberId ? resolveMemberAgent(params.agents, {
5173
+ memberId: requestedMemberId,
5174
+ memberName: readSingleValue(params.parsed, "member-name"),
5175
+ scope: params.scope
5176
+ }) : null;
5177
+ const organizationRootPath = normalizeOptionalValue(readSingleValue(params.parsed, "organization-root"));
5178
+ const validationMode = readDispatchValidationMode(params.parsed);
5179
+ const [organizationView, truthSnapshot] = await Promise.all([
5180
+ params.positionId || params.responsibilityId ? params.api.getOrganizationView({ organizationId: params.organizationId }) : Promise.resolve(null),
5181
+ organizationRootPath ? params.readDispatchTruthSnapshot(organizationRootPath) : Promise.resolve(null)
5182
+ ]);
5183
+ const positionTruth = truthSnapshot?.positions.find((position) => position.positionId === params.positionId) ?? null;
5184
+ const truthResponsibilityId = params.responsibilityId ?? positionTruth?.responsibilityIds[0] ?? null;
5185
+ const responsibilityTruthMemberAgentId = findResponsibilityMemberId(organizationView, truthResponsibilityId) ?? truthSnapshot?.responsibilities.find((responsibility) => responsibility.responsibilityId === truthResponsibilityId)?.memberAgentId ?? null;
5186
+ const positionTruthAgentId = positionTruth?.agentId ?? null;
5187
+ const truthMemberAgentId = positionTruthAgentId ?? responsibilityTruthMemberAgentId ?? null;
5188
+ const truthMember = findAgentById(params.agents, truthMemberAgentId);
5189
+ const dispatchMember = requestedMember ?? truthMember;
5190
+ if (!dispatchMember) {
5191
+ throw new Error("Dispatch send requires --member-id or truth-resolvable --position-id/--responsibility-id; scope/name/role fallback is now hint-only");
5192
+ }
5193
+ if (dispatchMember.isRoot) {
5194
+ throw new Error(`Member ${dispatchMember.id} is the CEO/root agent and cannot receive specialist dispatch notices`);
5195
+ }
5196
+ let rejectionReason = null;
5197
+ if (requestedMember && positionTruthAgentId && requestedMember.id !== positionTruthAgentId) {
5198
+ rejectionReason = "wrong_position";
5199
+ } else if (requestedMember && responsibilityTruthMemberAgentId && requestedMember.id !== responsibilityTruthMemberAgentId) {
5200
+ rejectionReason = "wrong_responsibility";
5201
+ } else if (params.positionId && positionTruth && !positionTruthAgentId) {
5202
+ rejectionReason = "stale_binding";
5203
+ } else if (!dispatchMember.sessionId || dispatchMember.status !== "active") {
5204
+ rejectionReason = "stale_runtime";
5205
+ }
5206
+ const validation = finalizeDispatchValidation({
5207
+ mode: validationMode,
5208
+ rejectionReason,
5209
+ requestedMemberAgentId: requestedMember?.id ?? null,
5210
+ positionTruthAgentId,
5211
+ responsibilityTruthMemberAgentId,
5212
+ liveBindingSessionId: truthMember?.sessionId ?? null,
5213
+ runtimeSessionId: truthMember?.status === "active" ? truthMember?.sessionId ?? null : null
5214
+ });
5215
+ if (validationMode === "hard" && rejectionReason) {
5216
+ throw new Error(`Formal dispatch rejected (${rejectionReason}) before session dispatch. Re-run with --validation-mode shadow only if you need observation without enforcement.`);
5217
+ }
5218
+ return {
5219
+ member: dispatchMember,
5220
+ validation
5221
+ };
5146
5222
  }
5147
5223
  function formatAgentRecord(agent, organizationId) {
5148
5224
  const lines = [
@@ -5165,12 +5241,27 @@ function formatDispatchReceipt(receipt) {
5165
5241
  `position_id=${receipt.notice.position_id ?? ""}`,
5166
5242
  `responsibility_id=${receipt.notice.responsibility_id ?? ""}`,
5167
5243
  `scope=${receipt.notice.scope}`,
5168
- `member_agent_id=${receipt.member?.agentId ?? receipt.business_ack?.memberAgentId ?? ""}`,
5244
+ `member_agent_id=${receipt.notice.member_agent_id ?? receipt.business_ack?.member_agent_id ?? receipt.member?.agentId ?? receipt.business_ack?.memberAgentId ?? ""}`,
5245
+ `session_id=${receipt.notice.session_id ?? receipt.business_ack?.session_id ?? receipt.member?.sessionId ?? ""}`,
5246
+ `runtime_session_id=${receipt.notice.runtime_session_id ?? ""}`,
5247
+ `delivery_session_id=${receipt.notice.delivery_session_id}`,
5248
+ `reply_session_id=${receipt.notice.reply_session_id}`,
5249
+ `machine_id=${receipt.notice.machine_id ?? ""}`,
5250
+ `machine_locality=${receipt.notice.machine_locality}`,
5251
+ `machine_reachability=${receipt.notice.machine_reachability}`,
5252
+ `route_type=${receipt.business_ack?.route_type ?? receipt.notice.route_type}`,
5253
+ `ack_type=${receipt.business_ack?.ack_type ?? receipt.notice.ack_type}`,
5254
+ `reply_mode=${receipt.business_ack?.reply_mode ?? receipt.notice.reply_mode}`,
5169
5255
  `member_label=${receipt.member?.label ?? ""}`,
5170
5256
  `current_status=${receipt.currentStatus}`,
5171
5257
  `delivery_status=${receipt.delivery.status}`,
5172
5258
  `business_ack_status=${receipt.business_ack?.status ?? "pending_ack"}`,
5173
- `ack_note=${receipt.business_ack?.note ?? ""}`
5259
+ `ack_note=${receipt.business_ack?.note ?? ""}`,
5260
+ `validation_result=${receipt.validation.validation_result}`,
5261
+ `rejection_reason=${receipt.validation.rejection_reason ?? ""}`,
5262
+ `position_truth_agent_id=${receipt.validation.position_truth_agent_id ?? ""}`,
5263
+ `responsibility_truth_member_agent_id=${receipt.validation.responsibility_truth_member_agent_id ?? ""}`,
5264
+ `validation_runtime_session_id=${receipt.validation.runtime_session_id ?? ""}`
5174
5265
  ];
5175
5266
  return lines.join("\n");
5176
5267
  }
@@ -5193,14 +5284,14 @@ ${chalk.bold("hicloud happy-org")} - Thin CLI sender for Happy Org dispatch/rece
5193
5284
 
5194
5285
  ${chalk.bold("Usage:")}
5195
5286
  hicloud happy-org agents [--organization-id <id>] [--json]
5196
- hicloud happy-org dispatch send --task-id <task> --scope <scope> [--member-id <id> | --member-name <name>] --allowed-paths <csv> [--forbidden-paths <csv>] [--position-id <id>] [--responsibility-id <id>] [--organization-id <id>] [--note <text>] [--wait-seconds <n>] [--json]
5287
+ hicloud happy-org dispatch send --task-id <task> --scope <scope> [--member-id <id>] --allowed-paths <csv> [--forbidden-paths <csv>] [--position-id <id>] [--responsibility-id <id>] [--organization-root <path>] [--validation-mode shadow|hard] [--organization-id <id>] [--note <text>] [--wait-seconds <n>] [--json]
5197
5288
  hicloud happy-org dispatch receipt <dispatch-id> [--organization-id <id>] [--json]
5198
5289
  hicloud happy-org repo process --root <path> [--request-id <id>] [--json]
5199
5290
  hicloud happy-org repo turn-report --root <path> --report-json <json> [--json]
5200
5291
 
5201
5292
  ${chalk.bold("Examples:")}
5202
5293
  hicloud happy-org agents --json
5203
- hicloud happy-org dispatch send --scope console-agent --task-id CONSOLE-1.1A-P1-001 --allowed-paths happy/packages/happy-console/**
5294
+ hicloud happy-org dispatch send --scope cli-agent --task-id CLI-1.7.7-001 --position-id position-cli --organization-root ./happy-org/acme --allowed-paths happy/packages/happy-cli/**
5204
5295
  hicloud happy-org dispatch receipt dispatch-abc123 --json
5205
5296
  hicloud happy-org repo process --root ./happy-org/acme --json
5206
5297
  `);
@@ -5282,21 +5373,33 @@ async function handleDispatchSendCommand(parsed, deps) {
5282
5373
  }
5283
5374
  const { organizationId } = await resolveOrganizationId(api, readSingleValue(parsed, "organization-id"));
5284
5375
  const agents = await api.listOrganizationAgents({ organizationId });
5285
- const member = resolveMemberAgent(agents, {
5286
- memberId: readSingleValue(parsed, "member-id"),
5287
- memberName: readSingleValue(parsed, "member-name"),
5288
- scope
5376
+ const resolvedTarget = await resolveFormalDispatchTarget({
5377
+ api,
5378
+ organizationId,
5379
+ agents,
5380
+ parsed,
5381
+ positionId,
5382
+ responsibilityId,
5383
+ scope,
5384
+ readDispatchTruthSnapshot: deps.readDispatchTruthSnapshot ?? persistence.readHappyOrgDispatchTruthSnapshot
5289
5385
  });
5290
5386
  let receipt = await api.createOrganizationDispatchNotice({
5291
5387
  organizationId,
5292
- memberAgentId: member.id,
5388
+ memberAgentId: resolvedTarget.member.id,
5293
5389
  taskId,
5294
5390
  scope,
5295
5391
  allowedPaths,
5296
5392
  forbiddenPaths,
5297
5393
  positionId,
5298
5394
  responsibilityId,
5299
- note
5395
+ note,
5396
+ requestedMemberAgentId: resolvedTarget.validation.requestedMemberAgentId,
5397
+ positionTruthAgentId: resolvedTarget.validation.positionTruthAgentId,
5398
+ responsibilityTruthMemberAgentId: resolvedTarget.validation.responsibilityTruthMemberAgentId,
5399
+ liveBindingSessionId: resolvedTarget.validation.liveBindingSessionId,
5400
+ runtimeSessionId: resolvedTarget.validation.runtimeSessionId,
5401
+ validationResult: resolvedTarget.validation.validationResult,
5402
+ rejectionReason: resolvedTarget.validation.rejectionReason
5300
5403
  });
5301
5404
  receipt = await waitForDispatchAck(api, {
5302
5405
  organizationId,
@@ -10250,7 +10353,7 @@ class AbortError extends Error {
10250
10353
  }
10251
10354
  }
10252
10355
 
10253
- const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CT1dgGsX.cjs', document.baseURI).href)));
10356
+ const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-D4TuE2VS.cjs', document.baseURI).href)));
10254
10357
  const __dirname$1 = path.join(__filename$1, "..");
10255
10358
  function getGlobalClaudeVersion() {
10256
10359
  try {
@@ -11573,14 +11676,14 @@ var launch = /*#__PURE__*/Object.freeze({
11573
11676
  const unifiedProviderExecutors = {
11574
11677
  claude: async (opts) => {
11575
11678
  const claudeOptions = opts.claudeOptions ?? {};
11576
- const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-BmW-_Yrl.cjs'); });
11679
+ const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-Dn1JJ8m9.cjs'); });
11577
11680
  await runClaude(opts.credentials, {
11578
11681
  ...claudeOptions,
11579
11682
  startingMode: claudeOptions.startingMode ?? (claudeOptions.startedBy === "daemon" ? "remote" : void 0)
11580
11683
  });
11581
11684
  },
11582
11685
  codex: async (opts) => {
11583
- const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-dmjiaB1v.cjs'); });
11686
+ const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-Dc2Rqb8W.cjs'); });
11584
11687
  await runCodex({
11585
11688
  credentials: opts.credentials,
11586
11689
  startedBy: opts.startedBy,
@@ -11589,7 +11692,7 @@ const unifiedProviderExecutors = {
11589
11692
  });
11590
11693
  },
11591
11694
  gemini: async (opts) => {
11592
- const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-CyERhKhw.cjs'); });
11695
+ const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-DQyuAba-.cjs'); });
11593
11696
  await runGemini({
11594
11697
  credentials: opts.credentials,
11595
11698
  startedBy: opts.startedBy
@@ -11672,7 +11775,7 @@ function shouldRunMainClaudeFlow(opts) {
11672
11775
  return;
11673
11776
  } else if (subcommand === "runtime") {
11674
11777
  if (args[1] === "providers") {
11675
- const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-Cl7kVs7K.cjs'); });
11778
+ const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-96cX402J.cjs'); });
11676
11779
  console.log(renderRuntimeProviders());
11677
11780
  return;
11678
11781
  }
@@ -11878,8 +11981,8 @@ function shouldRunMainClaudeFlow(opts) {
11878
11981
  const projectId = args[3];
11879
11982
  try {
11880
11983
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
11881
- const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-DeDVledu.cjs'); }).then(function (n) { return n.persistence; });
11882
- const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-DeDVledu.cjs'); }).then(function (n) { return n.api; });
11984
+ const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./api-C94O6IB2.cjs'); }).then(function (n) { return n.persistence; });
11985
+ const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-C94O6IB2.cjs'); }).then(function (n) { return n.api; });
11883
11986
  let userEmail = void 0;
11884
11987
  try {
11885
11988
  const credentials = await readCredentials2();
@@ -1,5 +1,5 @@
1
1
  import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(import.meta.url);import chalk from 'chalk';
2
- import { l as logger, k as encodeBase64, c as configuration, m as readCredentials, n as ensureSigningCredentials, r as readSettings, u as updateSettings, o as encodeBase64Url, h as delay, q as buildClientHeaders, t as decodeBase64, w as writeCredentialsLegacy, v as writeCredentialsDataKey, x as readDaemonState, y as HAPPY_CLOUD_DAEMON_PORT, z as clearDaemonState, B as packageJson, i as isAuthenticationRequiredError, C as acquireDaemonLock, D as writeDaemonState, A as ApiClient, E as releaseDaemonLock, F as validateProfileForAgent, G as getProfileEnvironmentVariables, I as clearCredentials, J as clearMachineId, K as processHappyOrgRepoRequests, L as HappyOrgTurnReportSchema, M as recordHappyOrgTurnReport, N as MessageContentSchema, O as buildSocketAuth, P as encrypt, H as HeadTailPreviewBuffer, Q as getLatestDaemonLog } from './api-DIFbsA6t.mjs';
2
+ import { l as logger, m as encodeBase64, c as configuration, n as readCredentials, o as ensureSigningCredentials, r as readSettings, u as updateSettings, q as encodeBase64Url, j as delay, t as buildClientHeaders, v as decodeBase64, w as writeCredentialsLegacy, x as writeCredentialsDataKey, y as readDaemonState, z as HAPPY_CLOUD_DAEMON_PORT, B as clearDaemonState, C as packageJson, i as isAuthenticationRequiredError, D as acquireDaemonLock, E as writeDaemonState, A as ApiClient, F as releaseDaemonLock, G as validateProfileForAgent, I as getProfileEnvironmentVariables, J as clearCredentials, K as clearMachineId, L as readHappyOrgDispatchTruthSnapshot, M as processHappyOrgRepoRequests, N as HappyOrgTurnReportSchema, O as recordHappyOrgTurnReport, P as MessageContentSchema, Q as buildSocketAuth, R as encrypt, H as HeadTailPreviewBuffer, S as getLatestDaemonLog } from './api-B3Zl8oHG.mjs';
3
3
  import { z } from 'zod';
4
4
  import fs, { writeFile as writeFile$1, rename, unlink as unlink$1 } from 'fs/promises';
5
5
  import os$1, { homedir } from 'os';
@@ -5084,6 +5084,20 @@ function normalizeRef(value) {
5084
5084
  const trimmed = value?.trim().toLowerCase();
5085
5085
  return trimmed ? trimmed : null;
5086
5086
  }
5087
+ function normalizeOptionalValue(value) {
5088
+ const trimmed = value?.trim();
5089
+ return trimmed ? trimmed : null;
5090
+ }
5091
+ function readDispatchValidationMode(parsed) {
5092
+ const raw = normalizeRef(readSingleValue(parsed, "validation-mode"));
5093
+ if (!raw || raw === "shadow") {
5094
+ return "shadow";
5095
+ }
5096
+ if (raw === "hard") {
5097
+ return "hard";
5098
+ }
5099
+ throw new Error(`Invalid --validation-mode value: ${raw}`);
5100
+ }
5087
5101
  function resolveMemberAgent(agents, opts) {
5088
5102
  const memberId = normalizeRef(opts.memberId);
5089
5103
  if (memberId) {
@@ -5098,29 +5112,91 @@ function resolveMemberAgent(agents, opts) {
5098
5112
  }
5099
5113
  const memberName = normalizeRef(opts.memberName);
5100
5114
  if (memberName) {
5101
- const exactMatches = agents.filter((agent) => !agent.isRoot && normalizeRef(agent.name) === memberName);
5102
- if (exactMatches.length === 1) {
5103
- return exactMatches[0];
5104
- }
5105
- if (exactMatches.length > 1) {
5106
- throw new Error(`Multiple members matched --member-name ${opts.memberName}; use --member-id instead`);
5107
- }
5108
- throw new Error(`No member found for --member-name ${opts.memberName}`);
5115
+ throw new Error("Dispatch send no longer supports --member-name as formal routing truth; use --member-id or truth-resolvable --position-id/--responsibility-id instead");
5109
5116
  }
5110
5117
  const scope = normalizeRef(opts.scope);
5111
5118
  if (!scope) {
5112
- throw new Error("Dispatch send requires --scope and either --member-id, --member-name, or a unique scope match");
5119
+ throw new Error("Dispatch send requires --scope and formal truth via --member-id or truth-resolvable --position-id/--responsibility-id");
5113
5120
  }
5114
- const candidates = agents.filter(
5115
- (agent) => !agent.isRoot && (normalizeRef(agent.name) === scope || normalizeRef(agent.role) === scope)
5116
- );
5117
- if (candidates.length === 1) {
5118
- return candidates[0];
5121
+ throw new Error(`Dispatch send no longer resolves formal targets from --scope ${opts.scope}; scope is hint-only now`);
5122
+ }
5123
+ function findAgentById(agents, agentId) {
5124
+ const normalizedAgentId = normalizeRef(agentId);
5125
+ if (!normalizedAgentId) {
5126
+ return null;
5119
5127
  }
5120
- if (candidates.length > 1) {
5121
- throw new Error(`Multiple members matched --scope ${opts.scope}; use --member-id instead`);
5128
+ return agents.find((agent) => normalizeRef(agent.id) === normalizedAgentId) ?? null;
5129
+ }
5130
+ function findResponsibilityMemberId(view, responsibilityId) {
5131
+ const normalizedResponsibilityId = normalizeRef(responsibilityId);
5132
+ if (!view?.home.responsibilityBoard || !normalizedResponsibilityId) {
5133
+ return null;
5122
5134
  }
5123
- throw new Error(`No member matched --scope ${opts.scope}`);
5135
+ return view.home.responsibilityBoard.items.find((item) => normalizeRef(item.responsibilityId) === normalizedResponsibilityId)?.memberAgentId ?? null;
5136
+ }
5137
+ function finalizeDispatchValidation(params) {
5138
+ return {
5139
+ requestedMemberAgentId: params.requestedMemberAgentId,
5140
+ positionTruthAgentId: params.positionTruthAgentId,
5141
+ responsibilityTruthMemberAgentId: params.responsibilityTruthMemberAgentId,
5142
+ liveBindingSessionId: params.liveBindingSessionId,
5143
+ runtimeSessionId: params.runtimeSessionId,
5144
+ validationResult: params.rejectionReason ? params.mode === "hard" ? "hard_reject" : "shadow_would_reject" : params.mode === "hard" ? "hard_pass" : "shadow_pass",
5145
+ rejectionReason: params.rejectionReason
5146
+ };
5147
+ }
5148
+ async function resolveFormalDispatchTarget(params) {
5149
+ const requestedMemberId = normalizeOptionalValue(readSingleValue(params.parsed, "member-id"));
5150
+ const requestedMember = requestedMemberId ? resolveMemberAgent(params.agents, {
5151
+ memberId: requestedMemberId,
5152
+ memberName: readSingleValue(params.parsed, "member-name"),
5153
+ scope: params.scope
5154
+ }) : null;
5155
+ const organizationRootPath = normalizeOptionalValue(readSingleValue(params.parsed, "organization-root"));
5156
+ const validationMode = readDispatchValidationMode(params.parsed);
5157
+ const [organizationView, truthSnapshot] = await Promise.all([
5158
+ params.positionId || params.responsibilityId ? params.api.getOrganizationView({ organizationId: params.organizationId }) : Promise.resolve(null),
5159
+ organizationRootPath ? params.readDispatchTruthSnapshot(organizationRootPath) : Promise.resolve(null)
5160
+ ]);
5161
+ const positionTruth = truthSnapshot?.positions.find((position) => position.positionId === params.positionId) ?? null;
5162
+ const truthResponsibilityId = params.responsibilityId ?? positionTruth?.responsibilityIds[0] ?? null;
5163
+ const responsibilityTruthMemberAgentId = findResponsibilityMemberId(organizationView, truthResponsibilityId) ?? truthSnapshot?.responsibilities.find((responsibility) => responsibility.responsibilityId === truthResponsibilityId)?.memberAgentId ?? null;
5164
+ const positionTruthAgentId = positionTruth?.agentId ?? null;
5165
+ const truthMemberAgentId = positionTruthAgentId ?? responsibilityTruthMemberAgentId ?? null;
5166
+ const truthMember = findAgentById(params.agents, truthMemberAgentId);
5167
+ const dispatchMember = requestedMember ?? truthMember;
5168
+ if (!dispatchMember) {
5169
+ throw new Error("Dispatch send requires --member-id or truth-resolvable --position-id/--responsibility-id; scope/name/role fallback is now hint-only");
5170
+ }
5171
+ if (dispatchMember.isRoot) {
5172
+ throw new Error(`Member ${dispatchMember.id} is the CEO/root agent and cannot receive specialist dispatch notices`);
5173
+ }
5174
+ let rejectionReason = null;
5175
+ if (requestedMember && positionTruthAgentId && requestedMember.id !== positionTruthAgentId) {
5176
+ rejectionReason = "wrong_position";
5177
+ } else if (requestedMember && responsibilityTruthMemberAgentId && requestedMember.id !== responsibilityTruthMemberAgentId) {
5178
+ rejectionReason = "wrong_responsibility";
5179
+ } else if (params.positionId && positionTruth && !positionTruthAgentId) {
5180
+ rejectionReason = "stale_binding";
5181
+ } else if (!dispatchMember.sessionId || dispatchMember.status !== "active") {
5182
+ rejectionReason = "stale_runtime";
5183
+ }
5184
+ const validation = finalizeDispatchValidation({
5185
+ mode: validationMode,
5186
+ rejectionReason,
5187
+ requestedMemberAgentId: requestedMember?.id ?? null,
5188
+ positionTruthAgentId,
5189
+ responsibilityTruthMemberAgentId,
5190
+ liveBindingSessionId: truthMember?.sessionId ?? null,
5191
+ runtimeSessionId: truthMember?.status === "active" ? truthMember?.sessionId ?? null : null
5192
+ });
5193
+ if (validationMode === "hard" && rejectionReason) {
5194
+ throw new Error(`Formal dispatch rejected (${rejectionReason}) before session dispatch. Re-run with --validation-mode shadow only if you need observation without enforcement.`);
5195
+ }
5196
+ return {
5197
+ member: dispatchMember,
5198
+ validation
5199
+ };
5124
5200
  }
5125
5201
  function formatAgentRecord(agent, organizationId) {
5126
5202
  const lines = [
@@ -5143,12 +5219,27 @@ function formatDispatchReceipt(receipt) {
5143
5219
  `position_id=${receipt.notice.position_id ?? ""}`,
5144
5220
  `responsibility_id=${receipt.notice.responsibility_id ?? ""}`,
5145
5221
  `scope=${receipt.notice.scope}`,
5146
- `member_agent_id=${receipt.member?.agentId ?? receipt.business_ack?.memberAgentId ?? ""}`,
5222
+ `member_agent_id=${receipt.notice.member_agent_id ?? receipt.business_ack?.member_agent_id ?? receipt.member?.agentId ?? receipt.business_ack?.memberAgentId ?? ""}`,
5223
+ `session_id=${receipt.notice.session_id ?? receipt.business_ack?.session_id ?? receipt.member?.sessionId ?? ""}`,
5224
+ `runtime_session_id=${receipt.notice.runtime_session_id ?? ""}`,
5225
+ `delivery_session_id=${receipt.notice.delivery_session_id}`,
5226
+ `reply_session_id=${receipt.notice.reply_session_id}`,
5227
+ `machine_id=${receipt.notice.machine_id ?? ""}`,
5228
+ `machine_locality=${receipt.notice.machine_locality}`,
5229
+ `machine_reachability=${receipt.notice.machine_reachability}`,
5230
+ `route_type=${receipt.business_ack?.route_type ?? receipt.notice.route_type}`,
5231
+ `ack_type=${receipt.business_ack?.ack_type ?? receipt.notice.ack_type}`,
5232
+ `reply_mode=${receipt.business_ack?.reply_mode ?? receipt.notice.reply_mode}`,
5147
5233
  `member_label=${receipt.member?.label ?? ""}`,
5148
5234
  `current_status=${receipt.currentStatus}`,
5149
5235
  `delivery_status=${receipt.delivery.status}`,
5150
5236
  `business_ack_status=${receipt.business_ack?.status ?? "pending_ack"}`,
5151
- `ack_note=${receipt.business_ack?.note ?? ""}`
5237
+ `ack_note=${receipt.business_ack?.note ?? ""}`,
5238
+ `validation_result=${receipt.validation.validation_result}`,
5239
+ `rejection_reason=${receipt.validation.rejection_reason ?? ""}`,
5240
+ `position_truth_agent_id=${receipt.validation.position_truth_agent_id ?? ""}`,
5241
+ `responsibility_truth_member_agent_id=${receipt.validation.responsibility_truth_member_agent_id ?? ""}`,
5242
+ `validation_runtime_session_id=${receipt.validation.runtime_session_id ?? ""}`
5152
5243
  ];
5153
5244
  return lines.join("\n");
5154
5245
  }
@@ -5171,14 +5262,14 @@ ${chalk.bold("hicloud happy-org")} - Thin CLI sender for Happy Org dispatch/rece
5171
5262
 
5172
5263
  ${chalk.bold("Usage:")}
5173
5264
  hicloud happy-org agents [--organization-id <id>] [--json]
5174
- hicloud happy-org dispatch send --task-id <task> --scope <scope> [--member-id <id> | --member-name <name>] --allowed-paths <csv> [--forbidden-paths <csv>] [--position-id <id>] [--responsibility-id <id>] [--organization-id <id>] [--note <text>] [--wait-seconds <n>] [--json]
5265
+ hicloud happy-org dispatch send --task-id <task> --scope <scope> [--member-id <id>] --allowed-paths <csv> [--forbidden-paths <csv>] [--position-id <id>] [--responsibility-id <id>] [--organization-root <path>] [--validation-mode shadow|hard] [--organization-id <id>] [--note <text>] [--wait-seconds <n>] [--json]
5175
5266
  hicloud happy-org dispatch receipt <dispatch-id> [--organization-id <id>] [--json]
5176
5267
  hicloud happy-org repo process --root <path> [--request-id <id>] [--json]
5177
5268
  hicloud happy-org repo turn-report --root <path> --report-json <json> [--json]
5178
5269
 
5179
5270
  ${chalk.bold("Examples:")}
5180
5271
  hicloud happy-org agents --json
5181
- hicloud happy-org dispatch send --scope console-agent --task-id CONSOLE-1.1A-P1-001 --allowed-paths happy/packages/happy-console/**
5272
+ hicloud happy-org dispatch send --scope cli-agent --task-id CLI-1.7.7-001 --position-id position-cli --organization-root ./happy-org/acme --allowed-paths happy/packages/happy-cli/**
5182
5273
  hicloud happy-org dispatch receipt dispatch-abc123 --json
5183
5274
  hicloud happy-org repo process --root ./happy-org/acme --json
5184
5275
  `);
@@ -5260,21 +5351,33 @@ async function handleDispatchSendCommand(parsed, deps) {
5260
5351
  }
5261
5352
  const { organizationId } = await resolveOrganizationId(api, readSingleValue(parsed, "organization-id"));
5262
5353
  const agents = await api.listOrganizationAgents({ organizationId });
5263
- const member = resolveMemberAgent(agents, {
5264
- memberId: readSingleValue(parsed, "member-id"),
5265
- memberName: readSingleValue(parsed, "member-name"),
5266
- scope
5354
+ const resolvedTarget = await resolveFormalDispatchTarget({
5355
+ api,
5356
+ organizationId,
5357
+ agents,
5358
+ parsed,
5359
+ positionId,
5360
+ responsibilityId,
5361
+ scope,
5362
+ readDispatchTruthSnapshot: deps.readDispatchTruthSnapshot ?? readHappyOrgDispatchTruthSnapshot
5267
5363
  });
5268
5364
  let receipt = await api.createOrganizationDispatchNotice({
5269
5365
  organizationId,
5270
- memberAgentId: member.id,
5366
+ memberAgentId: resolvedTarget.member.id,
5271
5367
  taskId,
5272
5368
  scope,
5273
5369
  allowedPaths,
5274
5370
  forbiddenPaths,
5275
5371
  positionId,
5276
5372
  responsibilityId,
5277
- note
5373
+ note,
5374
+ requestedMemberAgentId: resolvedTarget.validation.requestedMemberAgentId,
5375
+ positionTruthAgentId: resolvedTarget.validation.positionTruthAgentId,
5376
+ responsibilityTruthMemberAgentId: resolvedTarget.validation.responsibilityTruthMemberAgentId,
5377
+ liveBindingSessionId: resolvedTarget.validation.liveBindingSessionId,
5378
+ runtimeSessionId: resolvedTarget.validation.runtimeSessionId,
5379
+ validationResult: resolvedTarget.validation.validationResult,
5380
+ rejectionReason: resolvedTarget.validation.rejectionReason
5278
5381
  });
5279
5382
  receipt = await waitForDispatchAck(api, {
5280
5383
  organizationId,
@@ -11551,14 +11654,14 @@ var launch = /*#__PURE__*/Object.freeze({
11551
11654
  const unifiedProviderExecutors = {
11552
11655
  claude: async (opts) => {
11553
11656
  const claudeOptions = opts.claudeOptions ?? {};
11554
- const { runClaude } = await import('./runClaude-BvRjHUgF.mjs');
11657
+ const { runClaude } = await import('./runClaude-BrvxWJ9-.mjs');
11555
11658
  await runClaude(opts.credentials, {
11556
11659
  ...claudeOptions,
11557
11660
  startingMode: claudeOptions.startingMode ?? (claudeOptions.startedBy === "daemon" ? "remote" : void 0)
11558
11661
  });
11559
11662
  },
11560
11663
  codex: async (opts) => {
11561
- const { runCodex } = await import('./runCodex-B-B9MfOf.mjs');
11664
+ const { runCodex } = await import('./runCodex-DfYO-7YG.mjs');
11562
11665
  await runCodex({
11563
11666
  credentials: opts.credentials,
11564
11667
  startedBy: opts.startedBy,
@@ -11567,7 +11670,7 @@ const unifiedProviderExecutors = {
11567
11670
  });
11568
11671
  },
11569
11672
  gemini: async (opts) => {
11570
- const { runGemini } = await import('./runGemini-B9W7nfow.mjs');
11673
+ const { runGemini } = await import('./runGemini-C1_AOBlU.mjs');
11571
11674
  await runGemini({
11572
11675
  credentials: opts.credentials,
11573
11676
  startedBy: opts.startedBy
@@ -11650,7 +11753,7 @@ function shouldRunMainClaudeFlow(opts) {
11650
11753
  return;
11651
11754
  } else if (subcommand === "runtime") {
11652
11755
  if (args[1] === "providers") {
11653
- const { renderRuntimeProviders } = await import('./command-ZJ5yPOv4.mjs');
11756
+ const { renderRuntimeProviders } = await import('./command-CMZlS6zf.mjs');
11654
11757
  console.log(renderRuntimeProviders());
11655
11758
  return;
11656
11759
  }
@@ -11856,8 +11959,8 @@ function shouldRunMainClaudeFlow(opts) {
11856
11959
  const projectId = args[3];
11857
11960
  try {
11858
11961
  const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
11859
- const { readCredentials: readCredentials2 } = await import('./api-DIFbsA6t.mjs').then(function (n) { return n.R; });
11860
- const { ApiClient: ApiClient2 } = await import('./api-DIFbsA6t.mjs').then(function (n) { return n.S; });
11962
+ const { readCredentials: readCredentials2 } = await import('./api-B3Zl8oHG.mjs').then(function (n) { return n.T; });
11963
+ const { ApiClient: ApiClient2 } = await import('./api-B3Zl8oHG.mjs').then(function (n) { return n.U; });
11861
11964
  let userEmail = void 0;
11862
11965
  try {
11863
11966
  const credentials = await readCredentials2();
package/dist/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  require('chalk');
4
- require('./api-DeDVledu.cjs');
4
+ require('./api-C94O6IB2.cjs');
5
5
  require('zod');
6
- require('./index-CT1dgGsX.cjs');
6
+ require('./index-D4TuE2VS.cjs');
7
7
  require('node:child_process');
8
8
  require('node:fs');
9
9
  require('cross-spawn');
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'chalk';
2
- import './api-DIFbsA6t.mjs';
2
+ import './api-B3Zl8oHG.mjs';
3
3
  import 'zod';
4
- import './index-CFH8qcTw.mjs';
4
+ import './index-sqm5plVs.mjs';
5
5
  import 'node:child_process';
6
6
  import 'node:fs';
7
7
  import 'cross-spawn';
package/dist/lib.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var persistence = require('./api-DeDVledu.cjs');
3
+ var persistence = require('./api-C94O6IB2.cjs');
4
4
  var types = require('./types-DVk3crez.cjs');
5
5
  require('axios');
6
6
  require('chalk');